How do I make a player change its animation to obj animation

0 favourites
  • 3 posts
From the Asset Store
Players follower. use it for anything which follows the player
  • hey!

    Im dealing with a platformer game in which you can choose one of 8 players and i don't know how to program the "player"

    So i was thinking, I could make an object become another object animation if a variable is triggered...

    Something like

    On Created and IF variable Player1IsArcher = true ------>> set animation to Archer.AnimationName("Running")

    But it doesnt seem to work

    Archer.AnimationName("dead")

    throws wrong number of parameter before ("dead").

    PS: It will be a multi player game so it will have 2 characters and that's why i want to create an object that can change its animation to another object

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • leomachado666, you might need to add more information...

    you havent really shown us what you are trying to do..in the overall plan of your game..

    there are so many ways to change players views and swap out images or animations...

    you might need to break it down to simplistic form first then expand on the idea..

    As far as I know.

    one object sprite cannot call another object sprites specific animation view ..unless they are named the same per object..but it runs into troubles if you dont use Families..

    https://www.scirra.com/manual/142/families

    I would suggest that you make a Family of sprite objects that are all the character object sprites..

    This way you can call each family members animations by the same family name and it should work perfectly across the various classes of character..

    Does that make sense?

    use Families, its this kind of thing that Families are specifically used for ..

    groups of similar objects that you want to all affect with the same rules or events

    Each object sprite has its own animations ..but im pretty sure the animation names can be shared across different sprites....

    So you can just swap out several object sprites quite easily...but you need to make sure that you can call the right animation for the right object at the right time, in relation to the Family its in

    You are going to need a system that can handle that request....It might take more planning out than you have done so far...

    So first off, you would need an invisible platformer controller object with some instance variables that represent the player classes

    such as

    1-archer

    2-monk

    3-builder

    4-monkey

    etc etc

    Then you need a check to see which variable the player selected

    and then spawn the correct object sprite(with its animations) at the player controller sprite

    of course you may need to destroy the older or existing object character sprite ..

    then you need a way to trigger the right animations across the different sprites no matter what class is selected.

    ive done it before...by having a character menu screen but this is not the only way..you might want to swap character class in game...

    so if the player chooses archer you would would just check what the player chose by looking at what variable was selected and then create the required object (with its unique animations) at the player controller location and pin it..

    By the sounds of it you need to plan out your systems and code structure before you go doing things like this..

    Its always better to build systems that control your events rather than just dropping in events

    what I mean is..

    plan out and create a system that handles the player changing mechanic that you are trying to make

    its all about systems

    you need structure and a good plan to make it work...

    things I would consider are

    1- How does the player chose what class eg: is there a player select screen or is it done in the action part of the game or via a shop or whatnot?

    2- make sure the system is streamlined and optimised so that it doesnt take up all the processor time to swapp out the player objects..

    3-make it robust as well

    Basically you would need to elaborate alot more before you could get the best answer..

    but yeah....try swapping objects by relating it to a variable that tracks the players choice of character either in game or in menus...

    sprite objects can have unlimited animations im pretty sure so use the right object for the right job and you should be fine..

    hope that clears something up

  • I solved my issue by making only 2 "Players" and adding them a lot of characters sprites in different folders (Ninja,Archer,Knight) and added the variable "PlayerIs", and when the player goes to the selection screen he can change the variable to ninja,archer,knight etc,

    i added events like

    "If D is pressed" -- > "Player simulate right" -->

    sub event

    If "PlayerIs" = "ninja" ---> set animation to "NinjaRunning"..

    That actually solved it, now i'm going to learn more about families, thanks pal!!

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