How would I go about creating a button that moves my actor up and down?

mexicanchango

  • Posts: 17
so I am creating an endless game and I know that the buttons would have to be actors themselves, but I don't know much beyond that. Hope the image helps you understand what I'm trying to do.

mor911

  • Posts: 49
I know everyone says to not use built in stuff, but doesnt it come with some on-screen controls? I am not near my PC or I'd confirm. Check them out and use them as a starting point.

Indigo

  • Posts: 23
So I'm by no means an expert but here's what I would do:

It sound like you want to make the arrows actors right? you could also make them regions and do stuff basically the same way. Anyway assuming you are using actors for the arrows...

I'd work in the scene events and use an always loop. Then within that I'd have a conditional statement saying "IF mouse is pressed on {up arrow}  set {y} speed of {actor plane} to some number... OTHERWISE IF mouse is pressed on {down arrow}  set {y} speed of {actor plane} to some number...OTHERWISE set {y} speed of {actor plane} to zero

This works because you will only ever be clicking on one arrow at a time. first the program checks if you are clicking on the up arrow if you are it starts moving the plane up, if you aren't it checks if you are clicking down, if you aren't clicking anything it sets the up down movement to zero. preventing it from floating away.



If you are going for a more flappy bird style I'd take out the last bit of setting it to zero and just let the plane drift. Alternatively you could say "push {actor plane} in some direction" and then have linear damping in physics so it slows down

Hopefully this works for you!




mexicanchango

  • Posts: 17
Thank you guys for your reply I'll put post back if it works out.