sammae

Create a moving platform

Recommended Posts

Hi, 

I've been stumped by this for quite awhile and I feel as if it's so simple. I'm simply trying to create a platform that moves back and forth that a player can jump on. 

I got a platform to move by doing something like this:
 

platform = this.physics.add.sprite(300, 100, 'form');
platform.body.allowGravity = false;
platform.body.immovable = true;
platform.body.velocity.x = 100;

 

But it just keeps moving in one direction and I can't figure out how to make it collide with the player. I tried the:

this.physics.add.collider(this.player, platform);

But that did not work.

 

I just want a simple platform that moves back and forth that the player can jump on. Please any help is greatly appreciated, I'm ready to pull my hair out over this. 😞

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.