- Home /
Smaller object jumps around bigger when dragged by mouse cursor
Hello dear all users,
I have a problem with moving object with mouse cursor.
private Ray eyeRay;
private RayCastHit hit;
public void Update(){
if(allowMouseMoveUnit){
eyeRay = Camera.main.ScreenPointToRay(new Vector3( Input.mousePosition.x, Input.mousePosition.y,0) );//;)
if(Physics.Raycast(eyeRay, out hit, 1<<8)){
transform.position=new Vector3(hit.point.x,1.8f,hit.point.z);
}
}
When scene is empty capsule is moving under mouse, same when capsule is bigger than other objects on the scene. While there are bigger objects on the scene than capsule, and mouse is over them (bigger ones), capsule is jumping around or on them.
Usually all objects have colliders and some have Rigidbody etc.
How to fix this? I would like capsule to move into the other objects when they are bigger, like a "ghost object".
Thank you for time.
Your answer
Follow this Question
Related Questions
Moving a object around with mouse, rotating it with arrow keys and placing it. 1 Answer
Do something when mouse cursor "hits / looks at" object 2 Answers
how do i attach an object to the mouse on click 1 Answer
How to Rotate Camera around GameObject (Player) 0 Answers
Mouse Click and Spawn object 4 Answers