How to move the player

How to move the player when a button is clicked.

First things first. Think about what you want to achieve on screen when the right arrow is clicked. Possibly write it down somewhere, but how exactly do you write it down? It is a way of thinking which you need to figure out by doing, playing around, thinking about and solving puzzles. It takes time to develop this way of thinking and even solving certain simple problems can be a challenge in the beginning, but over time by solving these kind of problems it becomes easier and you will become fluent in this way of thinking.

Okay let’s get started.

So what exactly is it that you want to achieve on screen - Press the right arrow button then the player must move in a direction until the player collides with the box. Simple enough, but how do you achieve that?

Let’s think of it like this. How will the player know that it must move when the arrow is pressed down?

For some reason “if” comes to mind, but forget about “if” for now. The voice in your head must say the following / you must think of it in the following way:

Break it down into smaller parts.

Start at the beginning and work through each scenario in a systematic, logical way.

Figure out which objects you need to add to the scene (button, player, box, platform for player to stand on).

Which features should you add to which individual object.

Press button then emit event. Event name (right).

Player notice event (right) then player moves right.

But what is right?

Moving right is actually a difficult concept to explain and understand, if you need to explain exactly how something moves to the right.

So think about which features you need to attach to which individual toy in order to create what you want to create.

Button (Tap controller, Emit Event (right)).

Player features (Physics, On Event (right), Set linear velocity).

Box (Physics).

Click on the link below to try it in the editor.

Things to consider before you get started -

The game objects have already been added to the scene and the physics have been attached to the player.

Player = Physics (Dynamic).

Box = Physics (Static).

Player attach Physics.

Player attach On Event, Set linear velocity.

So you are attaching the Set linear velocity to the On Event (not directly to the player 🤔).

Set linear velocity x = 2 pushes the Physics body of the player to the right when the arrow is pressed down.

(Event (right) picked up by the player puts this into motion)…

If that makes sense, but remember no if’s for now.

Maybe read this post again.

Click the link below to start editing.

After you clicked the edit link above -

You must click on the “Play” button. The play button makes things happen on screen. Preview / test whatever you want to call it. Play around with different toys and different features and see what you can create.

You can also check out the posts on the forum, use the tutorials or send a direct message if you get stuck or have any questions.

There might even be a reward… 👾🕹️ but to accomplish this is definitely a reward in itself.

The possibilities of what you can create by applying the method and logic as explained above are endless!

If you can imagine it then you can create it.