- Home /
Making laser beam point in shooting direction C#
Ok, so basicly I'm making a 3d space shooter game, and I wan't to be able to shoot a laser. I have a projectile script, which I have attatched to a prefab that gets instantiated whenever I press the spacebar. My Projectile is in this case just a stretched colored capsule. The laser is moving in the direction I'm pointing, but the problem is, that my laser isn't laying down and pointing in the direction I'm shooting, its basicly standing up instead of laying down pointing towards it's target. So basicly I want this __ instead of this |. Hope it's clear what I mean.
Here is the projectile script:
void Update () { float amountToMove = ProjectileSpeed * Time.deltaTime; transform.Translate(Vector3.forward * amountToMove); Destroy(gameObject, 5);
}
And here I'm shooting my laser inside my player script:
if(Input.GetKeyDown("space"))
{
Instantiate(ProjectilePrefab, transform.position, transform.rotation);
}
I have also tried with Quaternion.identity as rotation, but doesn't make a diffrence. even if I change the standard facting direction of the beam before it get instantiated.
Hope someone can help with this Thanks in advance
I don't understand why this question is asked over and over again, though there is a usable search function available: http://answers.unity3d.com/search?q=face+to+target
Answer by teckno · Jan 17, 2016 at 05:28 PM
it may be the prefabs saved rotation witch is saved in the prefab so check the prefabs of the laser bolt
Your answer
Follow this Question
Related Questions
Enemy shoots player (Tower) 0 Answers
Problem with Shooting Accuracy 0 Answers
Character facing joystick direction 1 Answer
FPS recoil 1 Answer
Why is my gun shooting backward? 2 Answers