- Home /
Mouse follow on network
Hi, I'm having trouble when trying to make the player's object to follow the mouse pointer.
With any other kind of control, like the directional keys, everything works fine, but there's something wrong when I try the mouse following method.
It seems that all Game Objects (with the mouse follow script) in the scene follow all players' mouse positions in the network. So, the mouse position is not individual.
This is the current mouse follow script I'm using:
if(networkView.isMine)
{
mousePos = Input.mousePosition;
var ray : Ray;
ray = Camera.main.ScreenPointToRay(mousePos);
var hit : RaycastHit;
if(Physics.Raycast(ray, hit))
{
transform.position = Vector3.Lerp(transform.position, hit.point, 0.5 * Time.deltaTime);
transform.LookAt(Vector3(hit.point.x, 0, hit.point.z));
}
}
This should be as simple as
if (this gameobject is $$anonymous$$e on the network) then (follow my mouse) else (dont)
Are you sure that each gameobject is owned by each individual player?
If all gameobjects with this script attached follow the instance player's mouse, then that would mean networkView.is$$anonymous$$ine is true.
Check if networkView.is$$anonymous$$ine is true or false. That may give you your answer.
Your answer
Follow this Question
Related Questions
3D mouse position 0 Answers
Input.mousePosition Dead Zone - See gameplay 0 Answers
How to prevent mouse from leaving area 0 Answers
Camera.main.ScreenToWorldPoint works within Unity editor, but not in builds 0 Answers
Input.mousePosition for new networking 0 Answers