- Home /
How to make a ladder script
Hi, I am trying to do a ladder script for my game, but my script dosen't work.
Is there anything wrong with this script? My player falls through the ground and stuff with this script.
Script:
public var smooth : float;
public var Ladder : boolean = false;
public var newPosition : Vector3;
function Awake ()
{
newPosition = transform.position;
}
function Update ()
{
PositionChanging();
}
function PositionChanging ()
{
var positionA : Vector3 = new Vector3(576.3549, 17.97417, 174.8432);
var positionB : Vector3 = new Vector3(583.3901, 57.30544, 174.8432);
if(Input.GetKeyDown(KeyCode.W))
newPosition = positionA;
if(Input.GetKeyDown(KeyCode.S))
newPosition = positionB;
transform.position = Vector3.Lerp(transform.position, newPosition, smooth * Time.deltaTime);
}
Do you fall throught when you start or when you hit a button please be more specific with what is happening.
in your awake function you assign position to transform.position make sure that is the right position sounds like you are assigning yourself below the surface.
$$anonymous$$y first person controller just goes down through the floor, and I have not placed it inside the floor.
pull your controller up off the ground if its slightly in the ground it can fall throu
Answer by FL · May 26, 2013 at 05:26 PM
If you can stand over the ladder without the script, so you needs to raise a little the y positionA/B coordinates.
If you can't, so you needs a collider for your ladder.
How to make a ladder: http://answers.unity3d.com/questions/9931/how-do-i-create-a-climbable-ladder.html
Your answer

Follow this Question
Related Questions
How to lerp between cameras on a UI button click? 2 Answers
Why is .Lerp so bumpy? 3 Answers
Smooth Camera Angle Scroll 1 Answer
How to move along a group of waypoints at a certain speed? 2 Answers