Question by
raminbl · Feb 27, 2018 at 02:03 PM ·
bulletrotation axis
Bullet Tracers shooting in the wrong direction, how can I fix its rotation?
I am using this Bullet Tracer Script: https://www.davidstenfors.com/#!/tutorials/unity-tutorials/tracer-rounds-tutorial The tracer prefab should shoot in the same direction as the tracer spawn point (empty game object at the barrel of my gun), but it shoots 90 degrees off on the Y Axis. Also it is not possible to shoot up and down just on one axis which is weird.
This is the actual script which shoots the tracers:
using UnityEngine; using System.Collections;
public class ShootScript : MonoBehaviour {
public Rigidbody tracer;
public Transform tracerSpawnPoint;
[Space(10)]
public float tracerSpeed;
void Update () {
if (Input.GetMouseButtonDown (0)) {
//Set the rotation of the prefab to the same as spawnpoint
tracer.transform.rotation = tracerSpawnPoint.transform.rotation;
//Spawn the tracer
Rigidbody instantiatedTracer = Instantiate
(tracer, tracerSpawnPoint.transform.position, tracerSpawnPoint.transform.rotation)
as Rigidbody;
//Add velocity to the tracer
instantiatedTracer.velocity = transform.TransformDirection(Vector3.right * tracerSpeed);
}
}
}
tracer.jpg
(365.1 kB)
Comment
Your answer
Follow this Question
Related Questions
bullet wont move forward 2 Answers
Help with script for Bullet velocity 0 Answers
The bullet never destroyed!!! 2 Answers
PhotonNetwork wrong vector3 settings 1 Answer
MY effect dont destroy 0 Answers