How do I set limits to where objects can go

Hi everyone
I want to know how I can only make half the screen available to move in. For example. I made daisy the dinosaur and bird move but I wanted to split half the screen so that if bird tried to cross over to Daisy’s Sid it would just not let him. Like a barrier. I hope you smart people can help me and I you can that would mean a lot and I will give some credit for my project since I need this feature a lot so thanks if you can do it if not thanks for trying anyway. Ninja out

11 Likes

hi there, it’s great to meet you! Welcome to the forum!

uh for that you’d wanna ask @GameCodingCrazy123 and @tankt2016!

2 Likes

Look at the Daisy the dinosaur project and look at these: _____________ barriers. It’s easy:

When Daisy bumpes _______, change x by 5
3 Likes

What you could do is this:

When (self) is pressed
    Check Once if (Last Touch X) > ((Width)÷2)
        Set Position (Last Touch X) (Last Touch Y)
    End Check Once If
This would make it so that whatever object could not be dragged over halfway. Is this what you wanted?
4 Likes

@MISSION_IMPOSSIBLE has the code I’m pretty sure

2 Likes

Mission_Impossible has the correct code for that, and if you wanted something for bird if it was just moving on it’s own and not being dragged, you could modify that to be something like;

When (Self X Position) <= Width/2

set position X (self x position +1) y (self y position)

This code would have bird moving forward only if its current x pos was between 0 and half the screen width.
If you wanted it between 2 specific numbers, you could do something like:

When (100<=Self x position) and (self x position<=700)

// add whatever you want bird to do between these boundaries

That above code will make bird do something but only if it’s x position is between 100 and 700. And you can always change the 100 and 700 to whatever numbers you want , and that’ll change the boundaries.

I hope this helped, but I feel you still need anything else, feel free to @ me as @FearlessPhoenix. I’ll get the tag and will come help asap

6 Likes

I suggest using min and max. This will save you the If block. Everything else do what the 2 posts above are (I don’t really have time but I’ll elaborate later if needed)

7 Likes

I don’t think that there is an actual bird in DTD…

What is DTD?

DaisyTheDinosaur

Oh ok. I don’t think there is a bird there.

1 Like

Finally someone gets that that daisy and bird was just an example thank you cocoa voila

3 Likes

Hi guys thanks again for all the help and I think I know what to do but does anyone know how to make something invisible without it disabling the code? If there is Thani think I would have found out what I needed and thanks for being such a big help guy anyway ninja out

1 Like

I’m not sure exactly what you mean by that but you could always add a “Set Invisibility Percent 100” block and the object would be invisible

1 Like