How Would You Create Sword Combat?

JoshKahaneJoshKahane Member Posts: 470
edited November -1 in Working with GS (Mac)
Hi

As my character won't be shooting anything, its all sword combat in my game. How you you go about making it so that for example after 4 hits with a sword the enemy actor died?

The player would have to come into proximity of the enemy, then somehow hit them 4 times to bring their health down to 0 which is when they get destroyed. I have all attacking animations in place, but interaction. I have thought of a few things but I was wondering what your opinion was, thanks.

The best way I thought was still have an actor spawn and shoot like a gun (only it would be invisible so it looks like the sword is doing it), only that would slow performance down spawning and destroying actors all over the place.

Comments

  • BeyondtheTechBeyondtheTech Member Posts: 809
    Only working in theory, since I haven't developed in GameSalad yet (watching videos and reading tutorials), a sword attack would be triggered by a different animation, and possibly a different attribute. I'm thinking you can also change the collision characteristics so that the player would be invincible for that time being, but the enemy, also with collision characteristics or testing the player's attribute, if in proximity or contact with the player, would lose health until he's dead (I'd make him fall back so the health would only go down once per strike or contact).

    Hope that makes sense.
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    For a stabbing motion I would have an invisible actor that has its X and Y constrained to the stabber. You could try to have the invisible actor move when the stab button is touched, but that may conflict with the constrain behaviors. If it does, you could try making the invisible actor longer when the stab button is pushed so that more of it sticks out. If your player is 64pixels wide, offset the invisible sword by 29 pixels towards the front of the actor and have it be only 2 pixels long (so it is not sticking out at all) Then have it change to a longer length, but keep it under 64pixels or else it will stick out the back of the player as well.

    As you are experimenting with this I would leave the invisible actor visible until it works right. Then uncheck the visible box in the player's attributes.
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    or keep the invisible sword actor out at all times. Have the sword button change a boolean game attribute (game.stab) to true when pressed (otherwise false). Then in the bad guys have a rule:

    rule (ALL)
    1) when actor collides with invisible sword
    2) when game.stab is true

    Destroy this actor
    change game.score to game.score+1
    etc....

    Then have the animation in the main player and it will look like he stabbed the bad guy but really the sword was always there but it gets "activated" when the button is pressed.
  • JGary321JGary321 Member Posts: 1,246
    Set an self.attribute in your 'enemy actor' called HP. Set it to 4 or whatever you HP is going to be.

    Rule:
    When overlap or collide with hero actor
    Every 1 sec
    Change attribute self.HP to self.Hp -1

    When HP = or < 0
    Destroy Actor

    This works for melee range. Try this & let me know what happens. Technically it should work. The only reason it might not is if GS doesn't consider the 2 units touching as collision.

    -JGary
Sign In or Register to comment.