- Home /
How do i make the bullet go in the direction it was fired?
I am new to unity, I cannot figure out how to implement this in my script for bullet.
void update(){
float amtToMove = 10 * Time.deltaTime;
Transform.translate(vector3.right*amtToMove);
}
This makes the bullet go to the right. The bullet is instantiated in a different script. I want the bullet fired by the FPS to move in the direction it was fired. How do i manipulate x and z axis to do that. Thanks in advance.
Comment
Best Answer
Answer by animusrecro · Jul 07, 2012 at 03:45 PM
Firing Script
var myBullet: Transform; // Bullet Prefab
var shotSpot: Transform; // Shooting Location
function Update ()
{
if(Input.GetKeyDown("k"))
Instantiate(myBullet,shotSpot.position,shotSpot.rotation);
}
Your answer
![](https://koobas.hobune.stream/wayback/20220613073831im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Bullet only goes in a single way 0 Answers
Bullets Based on Orientation 1 Answer
Animation Play On Bullet Shot 1 Answer
Bullets kill enemy... but continue to travel? 1 Answer
Findinga GameObject Transform 1 Answer