I have a script that says when i hit pointA, lerp to pointB. It works great but when I go back to point A it wont repeat the lerp movement. Additionally, how would i set the Vector3 position to an actual gameobject, my pointA and pointB?
var pointA:Vector3;
var pointB:Vector3;
var time:float = 10.0;
var i:float = 0.0;
private var rate:float = 0.0;
var detector : ClimbDetectionScript;
var pointAobject : GameObject;
var pointBobject : GameObject;
function Update ()
{
MoveObject(this.transform, pointA, pointB, time);
}
function MoveObject (thisTransform : Transform, startPos : Vector3, endPos : Vector3, time : float)
{
rate = 1.0/time;
if (i < 1.0)
if (detector.startSpot == true)
{
i += Time.deltaTime * rate;
thisTransform.position = Vector3.Lerp(startPos, endPos, i);
}
}
1. I've tried resetting i to 0. All it does it make my player fall through the floor, its weird. 2. Would i put that as a var? Im trying to make so i can place an object into the inspector on this script to use its vector3
– inglipXReplies to your questions: 1). OK then, not sure what else to do without seeing your project in action. 2). Yes a public var that can be edited within the inspector.
– SubatomicHero1. With this i am attempting to make a climbing function on my game. Poimt A is the bottom of the wall , PointB is at the top. When i touch A, i want to smoothly go up to B. Currently when i hit A i move insidethe wall towards B, it doesnt move me on the y axis at all. After i have hit A once, and i have moved , i can longer repeat the movement when i hit A again. 2. Thank you
– inglipX