Posts

Showing posts with the label unity3d

Read file on the same folder as the Unity Application on MacOs

Read file on the same folder as the Unity Application on MacOs I am trying to find a way to read files that are in the same folder on my Unity build. It works perfectly on Windows, but MacOs don't find them... For now I have to put my files into the contents folder of the application, then use Path.Combine(Application.dataPath,fileName) Does anybody have an idea? Thank you! Where did you put the file you want to read? From the Editor? If so, where in the Eitor? – Programmer Jul 2 at 10:42 By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Product flavor specific gradle dependencies on Unity

Product flavor specific gradle dependencies on Unity Unity offers a custom mainTemplate.gradle file to be used as build.gradle after project export and for dependencies it uses the following; dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) **DEPS**} Problem here is that I have two productFlavors and I want some of the libraries to be product flavor specific. So the output is; compile(name: 'play-services-plus-10.2.0', ext:'aar') compile(name: 'play-services-tasks-10.2.0', ext:'aar') compile(name: 'unity-ads', ext:'aar') compile project(':gameCircle-2.4.2') What I'm looking for is an output like this; googleCompile(name: 'play-services-plus-10.2.0', ext:'aar') googleCompile(name: 'play-services-tasks-10.2.0', ext:'aar') compile(name: 'unity-ads', ext:'aar') amazonCompile project(':gameCircle-2.4.2') What is the best way to approach this...

C# code issue working on player movement and stamina system in unity

C# code issue working on player movement and stamina system in unity I am currently working on building a custom character movement system for my unity project but I seem to be having some problems with my code, no errors appear in the console and what I am trying to do is create a timer for a stamina system that will fatigued the player overtime and also a recharge system before the player can run again. The main issue is when I print the values of the current stamina multiple timers are being ran, also the values are not going up appropriately as they should any help would be appreciated Thankyou! using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityStandardAssets.CrossPlatformInput; public class PlayerController : MonoBehaviour { CharacterController characterControl; [SerializeField] float walkSpeed = 10f; [SerializeField] float sprintSpeed = 15f; [Header("Stamina")] [SerializeField] float maxStaminaDec...

Unity 2018 - NPC smoothly turning to face the Player while within range

Unity 2018 - NPC smoothly turning to face the Player while within range With the current code the NPC will detect the and turn towards the player with the desired animation playing. However, the NPC only snaps to face the player and does not continue to rotate as the player walks around the NPC while they are in range. I would like to modify this so that the NPC consistently and smoothly turns to face the character while the player is in range of the collider. I figured it would have something to do within void update, but since the function to turn is currently in onTriggerEnter it's a little confusing to a beginner such as myself. onTriggerEnter public class helloTrigger : MonoBehaviour { public Animator anim; public CharacterController player; public Transform Player; void Start() { player = GameObject.FindObjectOfType<CharacterController>(); anim = GetComponent<Animator>(); } void OnTriggerEnter(Collider other) { ...

adb logcat, only display custom log events?

adb logcat, only display custom log events? I'm using adb logcat -s Unity to view log output from my Android build. However, I'm getting lots of stuff that I don't always need: adb logcat -s Unity 08-10 15:53:25.956 17278 17297 D Unity : Sensor : Accelerometer ( 1) ; 0.002394 / 0.00s ; BMI160 accelerometer / Bosch 08-10 15:53:25.960 17278 17297 D Unity : Choreographer available: Enabling VSYNC timing 08-10 15:53:26.133 17278 17297 I Unity : Launching UI... 08-10 15:53:26.133 17278 17297 I Unity : UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object) 08-10 15:53:26.133 17278 17297 I Unity : UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object) 08-10 15:53:26.133 17278 17297 I Unity : UnityEngine.Logger:Log(LogType, Object) 08-10 15:53:26.133 17278 17297 I Unity : UnityEngine.Debug:Log(Object) Is there a way to only get messages I intentionally output, ie "Launching UI..." above? Currently I'm using Debug.Log()...

admob and unity / crash

admob and unity / crash Everything is fine in the console, but it crashes on the smartphone when the ad is requested. InterstitialAd interstitial; public void RequestInterstitial() { string adUnitId = "from admob"; interstitial = new InterstitialAd(adUnitId); AdRequest request = new AdRequest.Builder().Build(); interstitial.LoadAd(request); } public void ShowInterstitial() { if (interstitial.IsLoaded()) { interstitial.Show(); } } void Start() { string appId = "from admob"; MobileAds.Initialize(appId); } Any error message, debugging records, description of your issue? Very low effort question imho. – Rawrplus Jul 1 at 21:11 @Rawrplus where i can take it – Moonwar Jul 2 at 0:25 ...

How does Unity distinguish between Android and iOS

Image
How does Unity distinguish between Android and iOS Let's say we have make a mobile game based on accelerometer. We're using Input.accelerometer class. using UnityEngine; public class ExampleClass : MonoBehaviour { public float speed = 10.0F; void Update() { Vector3 dir = Vector3.zero; dir.x = -Input.acceleration.y; dir.z = Input.acceleration.x; if (dir.sqrMagnitude > 1) dir.Normalize(); dir *= Time.deltaTime; transform.Translate(dir * speed); } } This code works on Andoid and on iOS. Im wondering, how does Unity know if we're running the game on Android or iOS? I have checked UnityEngine.dll file and I did not find any if-else statement between the operating systems. This may be a shot in the dark, but when your running on Windows you are using the UnityEngine.dll... however I don't believe Android or iOS use the dll... I believe they use .so's or .a's why wo...

Adding a Unity3d project as dynamic feature module in a native app

Adding a Unity3d project as dynamic feature module in a native app I have a unity3d Android project, how can i integrate my unity3d android project as a dynamic feature module in an already existing native android app so that it would be downloaded on demand within the native android app. You can't. The close you might be able to get is using the AssetBundle to make the whole game – PerformanceFreak Jul 1 at 17:39 @PerformanceFreak can you please tell me why we cannot?. I have exported unity3d project as android studio project. So it is just like another android module. While i am trying to build, it is giving me manifest merge problem. – rohan bhatia Jul 3 at 10:06 ...