OK, I have a sphere(with a spherecollider and a rigidbody(not gravity) and a camera) and this sphere has the MouseLook(with x and y axes) then I make a simple movement for the sphere(I am doing something like forge in halo) and I add a script that makes a raycast forward of the player but this doesn’t work as I want because when I rotate my player the raycast is always the same not matters how I do it, I have try many thinks like:
if(Physics.Raycast(transform.position,transform.forward,hit,10.0)){
if(Input.GetKeyDown(KeyCode.Space)){
hit.collider.transform.tag = "selected";
}
}
if(Physics.Raycast(transform.position,Vector3.forward,hit,10.0)){
if(Input.GetKeyDown(KeyCode.Space)){
hit.collider.transform.tag = "selected";
}
}
var fwd = transform.TransformDirection (Vector3.forward);
if(Physics.Raycast(transform.position,fwd,hit,10.0)){
if(Input.GetKeyDown(KeyCode.Space)){
hit.collider.transform.tag = "selected";
}
}
And anyone of this seems to work, please help me I don’t know what is wrong