Restricting areas for user controlled motion paths

Mar 24, 2021

Hi

I'm building a pixel art inspired course where the user moves an avatar around the slide to interact with objects. I've set four paths (forward, back, up down) to the avatar and triggered them to the corresponding keys. 

The controls work but they allow the user to move the avatar off the slide. Is there a way to restrict areas of the slide to contain the character?

 

Cheers

 

Dan

3 Replies
Judy Nollet

Hi, Dan,

You should be able to do that using variables that track how far the avatar has moved vertically and horizontally. I'd use number variables, and then add 1 or subtract 1 from the value based on the movement. Those triggers would need conditions that stopped the addition or subtraction when the value reaches the number that corresponds to the edge of the screen.

You'd also need conditions on the triggers that move the avatar, so that they'd move the avatar or  provide a warning of some kind when the avatar reached the limit (based on the variable value). 

That type of programming can get complicated/tedious. I'd map out the coordinates on paper first, then follow that while doing the programming. 

Phil Mayor

As Judy says you ned variables and conditions.

Create two variables X and Y and then add triggers to subtract and add to either one when you click the button.

You should be able to add a reference to the slide for X and Y to show their values as they go off the screen and then I would disable to Left/Right/Up/Down button based on those values