- Home /
Ray extend, or get position of camera border
Hello,
I have 2d game top look. I am creating shooting script, all is done except this, that my bullets goes only to my ray point (place where I click)
My bullets should go in direction of mouse position to the end of screen.
Please help!
It would help if you could post the code your use for your bullet movement. Transform.$$anonymous$$oveTowards can be used to continuously move into a direction, for example.
Ok, so it's little complicated because I am using array of ray, because of every bullet has to go to place where mouse was clicked ( should change direction after next click)
But i re write it without array to only explain you my idea.
$$anonymous$$y character has a shooting script:
mousePosition = Input.mousePosition;
ray[i] = Camera.main.ScreenPointToRay(Input.mousePosition);
Object bullet= Instantiate(Prefab, gameObject.transform.position, Quaternion.identity);
And my bullet has script:
transform.position = Vector3.$$anonymous$$oveTowards(transform.position, target, speed * Time.deltaTime);
where target = ray.origin
Your answer
Follow this Question
Related Questions
For gameobject different ray, logic problem 0 Answers
How to use 3D model on 2D Game with collider and Gravity? Please give me some Guideline. 0 Answers
Collision with the ground kills the player using c#(Unity2D) 2 Answers
2D repeating obstacles with a random Y value 0 Answers
How do I Restrict movement for an Object Unity Mobile 0 Answers