Accessing Self Attribute of Spawned Actor

Ok. So in my game I have a cannon which shoots balls at the player, the player must tap on the balls to target them before they get to the main character. when the ball is tapped, it's self attribute Targeted is changed to true. I want the character to play an attack animation if the ball is targeted and hit him, and a different animation if the ball is not targeted.

How would I do this because there are multiple balls on screen at a time and the balls are spawned and are not in the scene to start off with.

Comments

  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    You cannot get the self attributes of an actor that has been spawned during gameplay. You might be able to come up with a way to have that actor send its value to a game attribute or table but you won't ever be able to directly access it.
  • artfishartfish Member, PRO Posts: 369
    @tendermer wouldn't it be sweet if the team could integrate some type of feature that would let us type on a prototype for example- when.attribute.scene. - Any attribute we want, even if it does not exist-.is.true , and then GS would check to see if the variable in the current scene exists, and if it does not, would just automatically turn off the rule and not break the game. Could be a simple workaround? hmm..but then the on and off properties of rules would have to be accesible...damn...it's never simple.. lol



  • MattcusMattcus Member Posts: 85
    Hopefully it will be possible in future updates. Does anyone have any ideas as to how I can work around this and still get it to work?
  • artfishartfish Member, PRO Posts: 369
    @Mattcus There's a ton of ways you could create a workaround. For example, Create a boolean called attackingtargeted. Now, create game attributes for your players x and y position. Constrain them within your player. Create an 2nd actor for you player that contains the attack animation. After the animation is done, have it change attribute attackingtargeted to false and then destroy itself. Put a rule in your cannon ball that says - when self.targeted is true and actor collides with player, change attacking targeted to true, spawn actor(with attack animation) at game.playerposx, game.playerpos.y. Put a rule in your player like if.game.attackingtargerted is true, change self.alpha to zero.

    Hope that made sense! ;)
Sign In or Register to comment.