Moving platform problem...

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.

125alt text125

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!!!

Yes it might be a script instance problem. I would recomend using a animation clip attached to the platform. To do that in the tabs up there where “Game” and “Scene” are theres a triangle at the end of the tab click on it choose animtion. After drag the animation tab/window at the bottom untill it becomes parrented by the scene. Then click at the red tod and give a nameto the animation. Once you’e done that move th red line across to 1:00 and move the platform where you would like it to move after one second. Once youre done with the animations go to the animation file and choose “Loop”. There now yore done, give a reply or a notice if you need help. Dont worry your animations are smooth.

  • Felipe

MoveVector = PlatformMoveVector(MoveAngle);
MoveVector = MoveVector * Speed;
MoveVector = MoveVector * Time.deltaTime;
MoveVector = MoveVector * MoveVectorLimit();

transform.Translate(MoveVector);

sugestion here… After reading your given code obviuosly Unity is driven nuts as to which movevector are you referring too. my sugested code is the following:
MoveVector = PlatformMoveVector(MoveAngle);
a = MoveVector * Speed;
b = a * Time.deltaTime;
c = b * MoveVectorLimit();

transform.Translate(c);