- Home /
Shoot A Raycast At A Specific Location?
Hello,
I want to be able to shoot a raycast from an objects transform (helicopter_gun) to a specific location.
That specific location is set by the user.
So, heres how it works:
The users clicks anywhere in the scene (using raycast from camera), that position of that click is then sent to the helicopter gun, and then that starts raycasting from itself, to that clicked position.
How would that be done?
So to save location of clicked area in scene, I'm thinking something like:
var savedLocation;
var hit : RaycastHit;
var ray = Camera.main.ScreenPointToRay (Input.mousePosition);
Physics.Raycast (ray, hit, 600, layerMask);
//something like: savedLocation = hit?
(with a if(Input..fire1 - in there somewhere)
Helicopter:
Physics.Raycast (transform.position, savedLocation, 10)??
This is just a rough outline - but if you could give me some idea - then that would be great.
Cheers
--EDIT --
I was also thinking that maybe - where the user clicks, a GameEmpty is initiated, and then the helicopter raycast could then use that as a 'track'
Your answer
Follow this Question
Related Questions
what is the best way to detect if an object has been clicked on? 1 Answer
Spawn Objects Where i click 2 Answers
Particle Instantiation problem. 0 Answers
Is object at least partly visible? 1 Answer