- Home /
For gameobject different ray, logic problem
Hello everybody.
I am creating 2d top camera game. My player can shot by holding mouse button, what I already have done.
Problem is when i move my mouse cursor during shooting. My bullets changes ray what I can understand why, but I don't know how to do it correctly. I mean that bullets which I already fired shouldn't go to new ray.
My only idea is, that I can do:
mousePosition = Input.mousePosition;
if(Input.mousePosition != mousePosition)
{
i++;
}
and then create an array of ray:
ray[i] = Camera.main.ScreenPointToRay(Input.mousePosition);
var bullet= Instantiate(Prefab, player.transform);
bullet.name = "bullet_"+i.ToString();
But I don't know how to say my bullets that they should go to new ray. Hard to say it, i am not English.
I mean that my bullets are prefabs, and bullet has other script which say where bullet should go.
Please help!
Your answer
Follow this Question
Related Questions
My bullets arent going the right direction 1 Answer
How to change direction without changing speed? 1 Answer
Ray extend, or get position of camera border 0 Answers
InvokeRepeating() not working. 1 Answer
2d top-down rpg direction check 1 Answer