Enemy attack
TaylorH1
Member Posts: 8
I'm working on a 2D hack and slash and can't figure out how to have enemy's coming from the left and right and advance at the main character and when they reach him have an attack animation that actually dose damage. Any virtual help would be great
Comments
A bit more detail about what you have so far and how you'd like it to work would be useful. But this is what I suggest.
1.Enemies coming from the left and right
Set up a timer behaviour to spawn enemies at a set location off screen (left and right) at random time intervals. This behaviour could be in the main character or in a separate invisible character.
2.Enemies advance at main character
Set up a rule in the enemy that when it's x position is greater than the x position of the main character it moves left, and when it's x position is less than that of the main character it moves right. To do this you may choose to set up a game attribute called x which you constrain to the x position of the main character. Alternatively you may be able to use a move-to or accelerate-towards behaviour and set the main character's x position as the target if that fits with your game.
3.Enemy attack animation
Set up a rule in the enemy that when it collides with hero an animation behaviour is triggered. You may want it to be triggered for a certain amount of time, in which case you would also use a timer behaviour and check run to completion.
4.Enemy attack damages main character
Set up an attribute in the main character called health with a value of 10 or any number you prefer, and a rule that when actor collides with enemy self.health reduces by a certain amount, or by a certain amount every half second if it should continue to cause damage after the first impact.
Hope something here is of use.
This will spawn enemies every 2 seconds or so. They will appear randomly on either side of the screen, head towards the player and when they get to him, do a silly attack animation and do damage to him (actually spawn a poker actor which damages the player and then destroys itself).
https://dropbox.com/s/iaosmcadxloawsw/Enemy%20Attack%20Template.zip?dl=0
Hey thanks guys I'm super new to gamesalad. So I really appreciate all the help I will definitely try then both!
Thanks
Taylor.