Answer by IvovdMarel
Using KISS principles, you could parent your Camera to another GameObject, that is placed on your floor. When you select the unit, move the parent GameObject to the selected unit. The camera offset...
View ArticleAnswer by IvovdMarel
You could use Unity's OnValidate method, which will run every time values have changed in the inspector. https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnValidate.html Simply check...
View ArticleAnswer by IvovdMarel
The best way to get around this is to use audioSource.PlayOneShot() as opposed to audioSource.Play(). Keep in mind that PlayOneShot requires an audioClip parameter, so you should make a public...
View ArticleAnswer by IvovdMarel
Keeping it simple: How about you create an Empty GameObject, parent the flashlight to it, and rotate it locally?
View ArticleAnswer by IvovdMarel
You can store the child's global rotation into a temporary variable. Quaternion childRotation = child.rotation; parent.localRotation = newParentOrientation; child.rotation = childRotation;
View ArticleAnswer by IvovdMarel
You are using Renderer.material.color as opposed to renderer.material.color Actually, you should use `GetComponent().material.color` Also, please keep in mind the following things: - When posting a...
View ArticleAnswer by IvovdMarel
You must have missed something somewhere. Environment Lighting: Intensity Multiplier should be 0 Environment Reflections: Intensity Multiplier should be 0 Make sure there are no lights in your scene If...
View ArticleAnswer by IvovdMarel
You should look at https://docs.unity3d.com/ScriptReference/Collider.ClosestPointOnBounds.html or just https://docs.unity3d.com/ScriptReference/Bounds.ClosestPoint.html
View ArticleAnswer by IvovdMarel
The error you are receiving also explains how to fix it (although I understand why it is not obvious when you read it). Consider to store it in a temporary variable: Vector3 pos = transform.position;...
View ArticleAnswer by IvovdMarel
You should use hit.point ( the point where it hit), not hit.distance (the distance from your object to the object that was hit). In addition, you should check the 'Use World Space' checkbox.
View ArticleAnswer by IvovdMarel
If your level names are the same as the text in the input-field, it's as simple as: string levelName = inputField.text; SceneManager.LoadScene(levelName); Of course don't forget to add using...
View ArticleAnswer by IvovdMarel
You are looking for the condition 'Has exit time' which you can find by selecting the transition arrow, above 'Settings'. Enable this, and ensure the exit time float inside 'Settings' is set to a...
View ArticleAnswer by IvovdMarel
Although I'm never opposed to using math, the AnimationCurve in Unity might be the better/easier/more customizable solution here. Untested code: public AnimationCurve curve; public Vector3 end; Vector3...
View ArticleAnswer by IvovdMarel
This code should work fine. Does your bullet actually reference the bullet object? Perhaps you are accidentally referencing a prefab. Also, you should not use Time.deltaTime in the FixedUpdate (called...
View ArticleAnswer by IvovdMarel
This question is still very vague, but let's see where this gets you. To store a currency, you just create an int. int currency = 0; To create multiple currencies for 2 (or more) teams, you should...
View ArticleAnswer by IvovdMarel
Trigger checking is NOT related to FPS, as it runs in the FixedUpdate, as opposed to the Update. https://docs.unity3d.com/560/Documentation/Manual/ExecutionOrder.html FixedUpdate (and Physics) by...
View ArticleAnswer by IvovdMarel
Line 15, if (gameObject.tag == "Player") should be if (collision.gameObject.tag == "Player") You are checking if the Platform itself has the Player tag.
View ArticleAnswer by IvovdMarel
Anything that does not move in the game should be made static. The advantage of making objects static is, simply said, that Unity can run some optimizations and your game will possibly run faster. Do...
View ArticleAnswer by IvovdMarel
The issue here is that your enemies array is null. Unity would serialize the array in the inspector automatically, therefore making it not-null (but just have a length of 0). You can either initialize...
View ArticleAnswer by IvovdMarel
The render order of UI elements should (almost) never be done by z-sorting. Instead, you should change the order of the objects in your hierarchy view. The lower the object in the hierarchy, the later...
View Article