Ok, I am getting really frustrated and feeling really stupid right now. I am new to unity but not to scripting and I am running into what is probably one of those minor differences between engines that takes weeks to figure out. All I am trying to do is basically figure out what my mouse is over. BUT the MouseOver() function is only called on individual objects, so for me to detect what is under the mouse at any given time every single object in the game would need to be running a script and returning that information to the object that actually needs said information. OR I could run a trace from the mouse and have it return the gameobject it hits.
Here is what I have tried:
var Visible = true;
function Start ()
function Update ()
//if right click
//Check what is under mouse
//set ray start to the position of our in game cursor object
var StartPos = transform.position;
//move start y just a bit so we dont hit the cursor itself (I should relay figure out how to make it ignore the cursor entirely)
StartPos.y = 2;
//I dont get how the heck this gets filled
var hitInfo : RaycastHit;
//Run a trace from the cursor down and store the information in hitInfo?
Physics.Raycast(StartPos, Vector3.down, hitInfo);
//Try to draw a line to see why the heck this is doing the weird stuff it is doing
//DOES NOT WORK NO GREEN LINE DRAWN AT ALL ANYWHRE!!!
Debug.DrawLine(StartPos, Vector3.down * (200), Color.green, 2, false);
//Record what has been hit for later use
//IT DOES NOT WORK JUST THROWS UP ERRORS
HitObject = hitInfo.collider;
//Try to figure out what we are actualy hitting
This code runs on the object I use for my cursor which also runs a script which positions it at the mouses position. For whatever reason (that I cant understand because Debug.DrawLine does not work) It seems to be drawing a ray not from the cursor strait down, but from the cursor to the cameras center. Making it useless since instead of telling me what is under the mouse it tells me what I am looking at. Which is always the player since the player is always in the center of the camera!
Thank you for any help you can provide.