How do I a random move using the 8 direction?

0 favourites
  • 6 posts
From the Asset Store
With this template you will learn how to use the GooglePlay Games native plugin
  • Please? Using animations for each direction.

  • Create an instance variable called "Direction".

    Then have an event that performs the action on the instance variable "set value" and type in "floor(random(1,9))". This generates a random number between 1 and 9 (not including 9) and then rounds it to the lowest integer, giving you a whole number between 1 and 8 (including both 1 and 8). Then you'll need an event that checks this instance variable and if it is 1 performs the action "simulate control: right" (The 'right' option appears after you select the 'simulate control' action).

    You'll actually need 8 different events with each one checking for a different number. Each event's will then do the "simulate control" action. For the diagonal directions, you'll have 2 actions. For example, if 2 is the number generated, then your event checking to see if the number is 2 will have one action for "Simulation control: right" and another for "simulation control: down", and your object will move down and right.

    An additional action for each event would be to set the animation sprite to a certain frame (or animation) for each number. I don't know the details of your game, so I can't give you a specific way of setting this up. It depends on what the object is doing, when/why it changes direction, etc.

  • Which event I create to check, I kind of lost myself here. Sorry.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • It's just a basic event. If sprite's instance variable is 1, then perform action X.

  • Like this?

  • deathangel Thank you man. )))

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)