Instantiated Objects Inside of Walls
when i instantiate an object (using raycast), it ends up stuck in the object that the raycast was collliding with. How do i fix this?
heres my code:
function Update () {
var ray = Camera.main.ScreenPointToRay (Input.mousePosition);
Debug.DrawRay (ray.origin, ray.direction * 50, Color.cyan);
var hit : RaycastHit;
if (Physics.Raycast (ray,hit)) {
if (Input.GetMouseButtonDown(0)) {
Instantiate(object, hit.point, transform.rotation);
}
}
}
Comment
Your answer
Follow this Question
Related Questions
Raycast not detecting? 0 Answers
How to get raycast to ignore objects behind a panel 0 Answers
Raycast + Collider + Mouse 0 Answers
Resize a one child object with raycasting or collision 0 Answers
Collide with an infinite plane 0 Answers