User Tag List

Results 1 to 3 of 3

Thread: Activating player sprite animations when player collision box moves

  1. #1
    No Products Registered

    Join Date
    Jan 2016
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Activating player sprite animations when player collision box moves

    So I created a collision box for my player since it will ensure collision is more accurate. I set the X and Y coordinates of the player sprite to always be that of the collision box which the player is actually in control of, and that seemed to do the job. Now my problem is that the actual player sprite has all these animations that the collision box doesn't, and I'm trying to figure out how to get the player sprite's animations to be activated as the player object (in this case, the collision box) moves around.
    There is a simple way to do this besides literally mapping out every player movement and key press, right? I'm hoping it's not something too overly complicated.

    Thanks for any hep!

  2. #2
    Clicker Fusion 2.5Fusion 2.5+ DLC
    casleziro's Avatar
    Join Date
    Mar 2013
    Location
    United States
    Posts
    679
    Mentioned
    14 Post(s)
    Tagged
    0 Thread(s)
    You'll need to compare to the velocity/input and state of your collision box regardless, unless you want to use something that does it automatically (default mmf2 platform movement comes to mind, but that's horrible don't use it). Mapping out keypresses isn't complicated, especially if you do something similar to my input "widget" ( input object.mfa ) where you just define what keyboard or controller input does what. Then you need to determine your animation states.

    If you have a platformer game for example, you would have roughly these states:

    -idle
    -walking
    -jumping
    -falling

    You need to first think of a way to detect ground. If you're using something like the Platform Movement Object, then great; there's a condition for standing on the ground built in to that. If you aren't, you can use an alterable value or flag, and shift your object down one pixel to check underneath them. This can be done in 3 events:

    always
    --> set ground to 0
    --> set y position of collision box to y("collision box")+1

    collision box overlapping a backdrop
    -->set ground to 1

    always
    --> set y position of collision box to y("collision box")-1


    Then you need to decide how to determine the animation state. Personally I would define them like so:

    IDLE
    ground = 1
    +x input = 0
    --> change animation to IDLE

    WALKING
    ground = 1
    +x input <> 0
    --> change animation to WALKING

    JUMPING
    ground = 0
    +y velocity < 0
    --> change animation to JUMPING

    FALLING
    ground = 0
    +y velocity >= 0
    -->change animation to FALLING


    Make sure you remember that Fusion reads the event sheet from top to bottom. You need to keep this in mind while structuring code. The best way to structure things is to group them and then usually:

    -check for input
    -check for ground under player
    -player physics (setting velocity for jumping/moving/etc)
    -player actual movement
    -check for ground under player again
    -pin player sprite to collision box
    -player animation

    This way input and ground happens before physics, physics happen before actual movement, ground is checked again after the player has been moved, and animation is determined by the end result. You can pin the player sprite before the second ground check or after the animation group if you want as long as it is placed AFTER the player actual movement. If you try pinning the sprite before then, it will cause inconsistencies in position and lag behind a bit when you move.

  3. #3
    No Products Registered

    Join Date
    Jan 2016
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks a lot for the reply. I appreciate you gave such detail. I'll make sure it gets put to good use!

Similar Threads

  1. Player Object - Animations and Toggle
    By Nelus in forum Fusion 2.5
    Replies: 0
    Last Post: 10th September 2015, 10:55 AM
  2. Store Player Animations Externally?
    By notjustinbailey in forum Multimedia Fusion 2 - Technical Support
    Replies: 1
    Last Post: 26th April 2015, 12:39 AM
  3. Replies: 9
    Last Post: 2nd December 2014, 06:59 AM
  4. Here's an Mfa that has player's animations not functioning! skydrive download
    By Aloan in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 5th January 2013, 02:24 PM
  5. Player moves with ship Problem.
    By Worf in forum Multimedia Fusion 2 - Technical Support
    Replies: 5
    Last Post: 7th January 2010, 08:56 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •