- Home /
Ladder script not working?
Hi. Im trying to make a 2D game, which will have ladders- but its not working. There are no errors. But its not working Heres my script, which I put on character.
var speed = 3.0;
function OnCollisionEnter(Bam : Collision)
{
if(Bam.tag == "Ladder")
{
var controller : CharacterController = GetComponent(CharacterController);
var forward = transform.TransformDirection(Vector3.up);
var curSpeed = speed * Input.GetAxis ("Vertical");
controller.SimpleMove(forward * curSpeed);
}
}
I also set the Ladders tags to Ladder and their collidors to Trigger. Help? Sorry. Im new to unity-java
Did you put a Debug.Log just bellow the function, to check if it is been called?
I changed the script to`var speed = 3.0;
var speed = 3.0;
function OnTriggerEnter(Bam:Collider){
Debug.Log("Checking for ladder");
if(Bam.Tag == "Ladder"){
Debug.Log("Touching Ladder..");
var controller : CharacterController = GetComponent(CharacterController);
var forward = transform.TransformDirection(Vector3.up);
var curSpeed = speed * Input.GetAxis ("Jump");
Debug.Log("Variables for movement made!");
controller.Simple$$anonymous$$ove(forward * curSpeed);
Debug.Log("$$anonymous$$oving Ready!");
}
}
Now im being spammed with Checking for Ladder- Yay! but It still doesnt detect a ladder and execute in the log here:
if(Bam.Tag == "Ladder"){
Debug.Log("Touching Ladder..");
Help?
Colliders
don't have tags, GameObjects
have tags, you have to do Bam.gameObject.tag
or something like that :)
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Click To Revert to Original Texture else Destroy script help 1 Answer
Have a 'Torch' script toggle on and off 1 Answer
[SOLVED] Enemy Script : Mob doesn't take damage 2 Answers
Need a Timer Script 1 Answer