I wrote a script to drive some platforms to move.
Here is my script.
void Update()
{
MoveVector = PlatformMoveVector(MoveAngle);
MoveVector = MoveVector * Speed;
MoveVector = MoveVector * Time.deltaTime;
MoveVector = MoveVector * MoveVectorLimit();
transform.Translate(MoveVector);
}
float MoveVectorLimit()
{
float tempValue;
float limitAngleIncreaseSpeed = 1f;
tempValue = Mathf.Sin(LimitAngle);
LimitAngle = LimitAngle + limitAngleIncreaseSpeed * Time.deltaTime;
if (LimitAngle > 360)
LimitAngle = 0;
return tempValue;
}
Vector3 PlatformMoveVector(float angle)
{
Vector3 tempVector = Vector3.zero;
tempVector.x = 1 / Mathf.Sin(angle);
tempVector.y = 1 / Mathf.Cos(angle);
return tempVector;
}
and I applied them to each platform I need them to move.But the problem is their renderers are not moving.I mean I can see their colliders moving in the editor window and colliders do work fine, but their mesh renderers are not moving.
125
125
Like this image.the green cube is the chocolate’s collider, I attached the script to these two chocolates, but only their colliders are moving, the bodys stay still…
BUT,if I attach the script on to only one chocolate, everything works fine.
so I wander how this is happening, is this some kind of script instance problem…asking for help, thanks so much!!!