- Home /
Mouse Sensivty Problem
Hello Everybody,
I have a problem with Mouse Sensivity. I have a code as that
var Prefab : GameObject ; var Prefab2 : GameObject ; var Prefab3 : GameObject ;
function Update () { if (Input.GetMouseButton(0)) { var ray: Ray = Camera.main.ScreenPointToRay(Input.mousePosition); var hit: RaycastHit;
if (Physics.Raycast(ray, hit)) {
Instantiate(Prefab, hit.point, Quaternion.identity);
}
}
}
I placing an item when i cliked the "mouse 0" but my problem about mouse sensivity when i clicked the "mouse 0" placed a lot of the same object in the scene.
How can i place only one object scene ?
Regards
Answer by Julian-Glenn · Jul 19, 2010 at 01:45 PM
Try this:
function Update () { if (Input.GetMouseButtonDown(0)) { var ray: Ray = Camera.main.ScreenPointToRay(Input.mousePosition); var hit: RaycastHit;
if (Physics.Raycast(ray, hit)) {
Instantiate(Prefab, hit.point, Quaternion.identity);
}
}
}
Answer by Mike 3 · Jul 19, 2010 at 01:31 PM
Use Input.GetMouseButtonDown instead of GetMouseButton. GetMouseButton returns true every frame the button is held, GetMouseButtonDown does it the frame you press it only
I try it but i take Assets/Scripts/PreFabScript.js(7,19): BCE0019: '$$anonymous$$ouseButtonDown' is not a member of 'UnityEngine.Input'.
i change my code as if (Input.$$anonymous$$ouseButtonDown(0)) {
But i take this error
@$$anonymous$$ike, can you update your answer with Input.Get$$anonymous$$ouseButtonDown, I am assu$$anonymous$$g that is what you meant.
Your answer
Follow this Question
Related Questions
Look rotation is "Snappy" 1 Answer
Mouse look Y axis sensitivity doesn't change 0 Answers
Mouse sensitivity 2 Answers
How to set mouse sensitivity through script 1 Answer
Changing Mouse Sensitivity With HotKeys 2 Answers