- Home /
How to shoot a bullet on a moving object,How to shoot a bullet from an object moving in the direction of motion
Hi all, I want to shoot a bullet from an object moving in the direction of motion. I wrote this script but the bullet don't match the direction of movement of the object,Hi all, I want to shoot a bullet from an object moving in the direction of motion. I wrote this script but the bullet don't match the direction of movement of the object.
if (Input.GetKeyDown("space"))
{
Instantiate(bullet, new Vector3(gameObject.transform.position.x, 3, gameObject.transform.position.z), Quaternion.identity);
}
Answer by logicandchaos · May 19, 2020 at 01:48 PM
you need gameObject.transform, just transform. You do need the rotation of the player.. like how do you move your player forward? just do the same thing with the bullets but faster.
Your answer
Follow this Question
Related Questions
2D C# destroy a GameObject on collision 2 Answers
what to put in vector3 when instantiating Gameobject at Gameobject? 2 Answers
Calculating Scrolling GameObject x position scrolling pass another GameObject x postion (2D Game) 1 Answer
How do you find the distance of multiple objects in a array 1 Answer
using Contains(gameObject) to find and destroy a gameObject from a list 2 Answers