- Home /
RTS unit movement
I've looked for a script and i'ave tried making invisable bullets which trigger an on collision function which tells a script to turn on but that only fired from the spawn which wasn't the exact poistion of the mouse pointer.
So i'ave decided to use raycasting and i have absouteley no idea how to do it so i'ave turned to your help.
I have a script where i would like the ray to orginate from maincam inside the first person controller. I've also sorted the unit move script but i need it to detect when the ray hits the unit it activates a bool value called "on", and i would like it so someone sends me a link to a nice website which is very detailed and helpful. basically i would like a website which tells me how to setup a ray send a ray and detect a ray when it hits an object with a tag called unit.
so in simple talk please may you give me a link to where i can find all the infomation out or tell me, the choice is yours
Answer by puttly · Jul 16, 2012 at 09:02 PM
Have you looked at the Raycast function in the documentation?
[http://docs.unity3d.com/Documentation/ScriptReference/Physics.Raycast.html][1]
I don't understand exactly what you are looking for but it seems to be an understanding of Raycast. [1]: http://docs.unity3d.com/Documentation/ScriptReference/Physics.Raycast.html
Ok i have a ray controller script which fires rays when i click, but now I need to make an receveing ray script i'ave started on it but it dosen't know the name of the ray.
if (Physics.Raycast (transform.position, fwd, 10)) { on = true; }
I have also tried to make a detecter inside the ray controller buy using if(fwd.collider.gameObject.tag == "unit") but it came up with 'UnityEngine.vector3.collider' not found
Your answer
![](https://koobas.hobune.stream/wayback/20220613074245im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
RTS Grid Idea? 1 Answer
What is a 2D Array? 3 Answers
My unit won't stop moving (RTS) 0 Answers