Moving Platforms

Does anybody know how to make a moving platform with Collision?

Try looking at a first project. https://playcanvas.com/editor/project/530412
use same script just add the script to the entity you want to move too

Ok Thanks! (Post needs 20 characters so )tynbtshrrghr

… No I mean that it moves on a linear path set without any input.

like move on its own? like AI? if so check out this: https://playcanvas.com/editor/scene/365100
its used in legacy but you can convert it… if u need some more help let me know

I need help XD______

Do you need something like this? https://playcanvas.com/editor/scene/747522

It seems this project is private or deleted.

Ok so from what i understand is that you want the Object to move in a path right? here is an example of what that path could look like in code:

Example.attribute.add('limitA', 'number', -1);
Example.attribute.add('limitB', 'number', 1);
Example.attribute.add('velocity', 'number', 1);
......
//in update function
            var currX = this.entity.getPosition().x;

            if (((currX <= this.limitA) && (this.velocity < 0)) ||
                ((currX >= this.limitB) && (this.velocity > 0))) {
                this.velocity = -this.velocity;
            }

            this.entity.translate(this.velocity * dt, 0, 0);
        }

This code makes the entity move back and forth of course this can be changed as the original code is here
Let me know if this helps…

Yes, the project was private. Try again.

1 Like