- Home /
Moving Things Like Amnesia
Hi i'm working on a game like amnesia and I'm wondering how to show a hand image when looking at rigid bodies. I've looked all through the forums for help but can't find any. I'm sorry if you found the title a bit misleading I would be thankful for a script or a link or explanation on how it is done. Thanks.
Answer by deltamish · Jan 01, 2013 at 04:19 PM
Hi,Use this Script Make sure the camera you are using is tagged MainCamera
var hand:GUITexture;
function Update(){
var hit:RaycastHit;
var pos = Camera.main.ViewportPointToRay(Vector3(0.5,0.5,0));
if(Physics.Raycast(pos,hit,1000)){///Casts a ray from centre of screen upto 1000 units
if(hit.rigidbody){//if we are loooking at a rigidbody
hand.enabled = true;
//your code to move rigidbody
}
}
}
Your answer
Follow this Question
Related Questions
How to actually make an objective to my game 1 Answer
cause the object appears in front of the player when colliding with another object 0 Answers
getting udp package info inside unity (GlovePIE) 0 Answers
Unity3D - RTS Game - Instantiate object on buttonclick and make it follow the cursors position 2 Answers
Ambient Script CS0163 1 Answer