Moving Platforms


#1

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


#2

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


#3

Ok Thanks! (Post needs 20 characters so )tynbtshrrghr


#4

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


#5

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


#6

I need help XD______


#7

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


#8

It seems this project is private or deleted.


#9

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…


#10

Yes, the project was private. Try again.