Legacy Animation Walk Speed relative to Movement Speed
Hello, I am calculating the movement speed of a navmesh agent like this: float currentSpeed = 0; Vector3 currentPosition = Vector.zero; Vector3 lastFramePosition = Vector3.zero; void Awake() {...
View ArticleHow to store Gizmo (grid) Cube positions in Vector3 list at game start?
I have written this script to create a grid of gizmo cubes: using UnityEngine; using System.Collections.Generic; public class Grid : MonoBehaviour { public int[] rows; //public int[] columns; //not...
View ArticleNeed Help adding Main Color Property to a complicated Shader
Good day! I have gotten my hands on a great hair shader, the best i've ever seen so far. Now **I need to change the main color**, but I don't have a clue how this can be done. I googled a lot and tried...
View ArticleRandom.insideUnitSphere doesn't work as expected
Does anyone know why this snippet returns a position around world space zero? (the transform is a child) float radius = 5; float zDistance = 5; targetPosition = new Vector3(Random.insideUnitSphere.x *...
View ArticleConstant Transform Lerp
Is it bad practice to let a transform constantly re-position and rotate itself to a target with Vector3.Lerp and Quaternion.Lerp? For example: Camera.main.transform.position =...
View ArticleIncorrect usage of Vector3.Dot?
Hello, I am trying to make a game similar to Rimworld or Prison Architect, so I have a AI controlled sprite character with 4 different sprites for each main direction and I'm currently trying to...
View Articlezoom problem with GUI Box that follows a character
I have a GUI box following a sprite character in a 2d Top Down Game. If I zoom in, the GUI box goes up, if I zoom out, the GUI box moves down, instead of staying at the point it was drawn at game...
View ArticleArray = null when passing as parameter
Straight to the point. The following code is in a script that executes before all other scripts: public static AudioClip[] FootstepSounds; void Start() { FootstepSounds = Resources.LoadAll("Sound...
View ArticleHow to add one onClick Event to multiple UI buttons
Hello, I must be missing something essential here. This is what I've tried: void Start() { // Assign the callback to all buttons foreach(Button subbutton in canvas.transform.GetComponentsInChildren())...
View ArticleUnityEditor GenericMenu - Problem with 'AddItem' in Foreach Loop
I'm working on a custom inspector and I'm trying to populate a GenericMenu with the content of a string array like this: public override void OnInspectorGUI() { if(GUILayout.Button("Add Type")) { var...
View Article