- Home /
Trouble with java raycast scripts to open a door
please guys help.... i do everything i saw in that tutorial video....but this script is not working....please guys help me!!!!please!!!!!!!!!!!
here this code
var rayCastLength = 5;
function update() { var hit : RaycastHit;
//Check if we're colliding
if(Physics.Raycast (transform.position, transform.forward, hit, rayCastLength))
{
//... with the door
if(hit.collider.gameObject.tag == "door")
{
//open the door!
hit.collider.gameObject.animation.Play("door_open");
}
}
please guys help me to found this problem...tnx
Answer by FirePlantGames · Jan 03, 2014 at 05:10 PM
also do you have the door tagged as door? do you have an animation attached to the gameObject that your hitting with the raycast?
try this: var rayCastLength = 5;
function update() { var hit : RaycastHit;
//Check if we're colliding
if(Physics.Raycast (transform.position, transform.forward, hit, rayCastLength))
{
//... with the door
if(hit.gameObject.tag == "door")
{
//open the door!
hit.gameObject.animation.Play("door_open");
}
}
Answer by HellGate · Jan 03, 2014 at 05:28 PM
i try that you said....but this error showed to me gameObject' is not a member of 'UnityEngine.RaycastHit'.
Your answer
Follow this Question
Related Questions
Trouble with java raycast scripts to open a door 0 Answers
Rotation Y axis is bugged. 2 Answers
Begginers question, Simplifing a script, opening two doors with 2 overlapping triggers. 1 Answer
importing exporting Animation help. 1 Answer
Play Animation on Raycast *open and close some objects* 0 Answers