Correct bolt direction and rotation
Tryed to make laser bolt-shooting gun like in "Space Shooter" tutorial but for 3d. Made two scripts. First for instantiating:
Instantiate (Shot,ShotSpawn.position,ShotSpawn.rotation);
Where Shot is my bolt prefab, ShotSpawn is empty gameobject on my gun. Second for bolt movement:
void Start()
{
GetComponent<Rigidbody> ().velocity = transform.forward * Speed;
Destroy (gameObject, DestroyOn);
}
The result is that bolt always facing toward z axis (forward). I want to make it relative to my ship's angle (ShotSpawn's direction). Any ideas?
Answer by Kelborn · Apr 27, 2016 at 04:40 PM
Ok, the problem of rotation was in the ShowSpawn gameobject rotation in ediot. Have no idea why, but when blue axis looks forward everything works fine. The problem of direction was solved by using transform.parent, not just transform. Also have no idea. If everyone can explain me the solving, I'd be grateful.
Your answer
Follow this Question
Related Questions
Struggling to get the rotation the player is moving in. 1 Answer
Controller Rotation returns to Zero when there is no movement. 0 Answers
How can I find direction with known 2 projection angles on xz and yz planes? 2 Answers
Convert Local Position To Global on a Child Object 0 Answers
How to make One More Line game? 0 Answers