Hello am trying to make a shooting game in which when a key, for example space, is pressed the game waits for 0.3 seconds before the gun shoots because there is an animation that needs to played before that the bullet leaves the gun. Here is a code that I have been trying to use:
I finally was able to figure it out by looking deeper into the LookAt function. Thanks so much for pointing me in the right direction! I would give you points but I have none. lol Here is how I was able to get it to work. I added this code after I set a new waypoint: Quaternion rotation = Quaternion.LookRotation(waypoints[cur].transform.position - transform.position, transform.TransformDirection(Vector3.up)); transform.rotation = new Quaternion(0, 0, rotation.x, rotation.w);
I finally was able to figure it out by looking deeper into the LookAt function. Thanks so much for pointing me in the right direction! I would give you points but I have none. lol Here is how I was able to get it to work. I added this code after I set a new waypoint: Quaternion rotation = Quaternion.LookRotation(waypoints[cur].transform.position - transform.position, transform.TransformDirection(Vector3.up)); transform.rotation = new Quaternion(0, 0, rotation.x, rotation.w);
– kunald