Advice needed on best practise in bigger projects

0 favourites
  • 3 posts
From the Asset Store
Best car suspension with spring effect and very cool terrain generation.
  • hello,

    I was wondering for a best practise for the following example:

    Player (sprite) has animation Idle and Running.

    Example:

    if sees enemy: play animation running

    if does not see enemy: play animation idle

    If player is running: play animation running

    if player is not running: play animation idle

    Now I think: I also want a hit animation.

    The only way I know to edit the code (and insert the hit animation) is to use global or instance variables to make a clear seperation of what a player is doing and when an animation to play.

    I would add:

    if player overlaps SomeSprite: play animation hitting.

    My example from above would change to:

    if sees enemy, and does not overlap SomeSprite: play animation running

    if does not see enemy: play animation idle

    If player is runningand does not overlap SomeSprite: play animation running

    if player is not running: play animation idle

    By adding something new in the same "area", I have to edit all existing events that have to do with this. (because it effects eachother)

    Can this be done easier/more efficient?

  • Use a Global Variable to determine what animation is being played as a trigger/

    Global Variable: Player.Action

    Add that as a condition to your event:

    if sees enemy: play animation running

    if does not see enemy: play animation idle

    Set Player.Action to 1

    If player is running: play animation running

    if player is not running: play animation idle

    Set Player.Action to 2

    Now you can define which action is happening for other events.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thank you, I will look into that.

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