- Home /
my ladder script not working plz help me
Hello everybody i not good at c# but i tried some scripting with script api.I tried to make a ladder system with vector3 up ,and ontriggerstay but not worked.i put a video u can learn better with video and that is my codes
using UnityEngine; using System.Collections;
public class Merdiven : MonoBehaviour {
void OnTriggerStay(Collider other)
{
transform.position += Vector3.up * Time.deltaTime;
}
Answer by doublemax · Oct 22, 2016 at 10:40 PM
As visible in the video, you're chaning the position of the ladder instead of the player. So try this:
void OnTriggerStay(Collider other)
{
other.gameObject.transform.position += Vector3.up * Time.deltaTime;
}
Sorry mate nothing happened :( Ladder and player didnt move with this script
This script is attached to the ladder? Add a Debug line to check with which object it actually collided. This might give a hint about what's wrong:
void OnTriggerStay(Collider other)
{
Debug.Log("collided with " + other.gameObject.name );
other.gameObject.transform.position += Vector3.up * Time.deltaTime;
}
Your answer
Follow this Question
Related Questions
My Animation Loops 3/4 of the way through 3 Answers
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
How to destroy and instantiate something without breaking this code 1 Answer
Idle game currency converter 2 Answers