- Home /
Question by
DAlturG · May 15, 2016 at 01:34 PM ·
androidjavascripttransformtransform.positionlag
Script causing huge lag
I've got a movement script where when an object is set active from an object pool, it moves along a curve smoothly. There are many objects in the scene at the same time with similar scripts to this. Could anyone help me stop the lag? The lag is only seen on an android device. Here's the script that's causing the lag:
public var waypointArray2 : Transform[];
public var rotation : float = 1.0f;
public var where : Transform;
var t : float;
function Update ()
{
transform.position = Spline.InterpConstantSpeed(waypointArray2, t, EasingType.Linear , true, true);
t += Time.deltaTime * 0.2;
transform.Rotate (0, rotation, 0);
}
function OnTriggerEnter(other : Collider)
{
if(other.tag == "destroyer")///go back to start after if collides
{
t = 0;
gameObject.transform.eulerAngles = new Vector3(0,273,0);
gameObject.SetActive(false);
}
}
function OnDrawGizmos()
{
iTween.DrawPath(waypointArray2);
}
Comment
Your answer
Follow this Question
Related Questions
Alternative to using transform.translate and transform.position for moving objects exact values? 1 Answer
Changing water level 0 Answers
Android lag 0 Answers
transform.Translate() effect is being reverted 0 Answers
Testing JavaScript on an Android device 2 Answers