How Do I Create A Basic Attack?

FallingBoxStudiosFallingBoxStudios Freelance Graphic DesignerMember Posts: 822
Hi,
What I'm trying to create is a basic attack, but I don't want to create an animation of my character swinging a sword (or something like that…), I'll try to explain better, basically my character is just a box, it has no face or anything, its just a coloured box, and I would like to make him have a power attack, I have created an animation of the weapon swinging, basically what I'm trying to say is I want to have the weapon actor hidden behind my character, so the weapon actor will follow my character, and when a button is pressed, the attack animation plays, I'm pretty bad at explaining things… I hope it was clear enough, thanks.

Comments

  • KevinCrossKevinCross London, UKMember Posts: 1,894
    edited September 2013
    Keep your weapon actor off screen until a certain key/button is pressed. When that button or key is pressed, move the weapon to where the character is, run any animation on the weapon actor, check for any collissions, and then when the power attack has finished move it back off the screen i.e. x = -100 and y = -100.

    Or just spawn the weapon actor in front of your character, run any animation, check for collisions and then destroy it.
  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    I've been following these threads from falling box. Who's building this game him or Kevin cross? lol
  • KevinCrossKevinCross London, UKMember Posts: 1,894
    If I can't build my own games then I might as well help others build theirs.
  • FallingBoxStudiosFallingBoxStudios Freelance Graphic Designer Member Posts: 822
    edited September 2013
    @FryingBaconStudios
    I've been following these threads from falling box. Who's building this game him or Kevin cross? lol
    Lol :)) I'm just really new to GameSalad,
    @KevinCross Has been a big help :)
  • FallingBoxStudiosFallingBoxStudios Freelance Graphic Designer Member Posts: 822
    @KevinCross
    Keep your weapon actor off screen until a certain key/button is pressed. When that button or key is pressed, move the weapon to where the character is, run any animation on the weapon actor, check for any collissions, and then when the power attack has finished move it back off the screen i.e. x = -100 and y = -100.
    Or just spawn the weapon actor in front of your character, run any animation, check for collisions and then destroy it.
    But my character jumps and walks all around the screen, so I need the weapon actor to actually follow the main actor, does this method do that?
  • KevinCrossKevinCross London, UKMember Posts: 1,894
    If you spawn it each time you can constrain it to the characters position plus any offset to get the weapon to sit where you want.
  • FallingBoxStudiosFallingBoxStudios Freelance Graphic Designer Member Posts: 822
    edited September 2013
    @KevinCross Okay Thanks, but how do I constrain the weapon actor to the main actor?
  • -Timo--Timo- Member Posts: 2,313
    make 2 integers (lets say we call it playerx and playery) go into the player/main actor on constrain attribute game.playerx to self.position.x
    and constrain attribute game.playery to self.position.y

    go into the weapon and
    constrain attribute self.position.x to game.playerx
    and contrain attribute self, position.y to game.playery

    now the weapon stays in the middle of the player.
    if you want it to be a little to the right then
    constrain attribute self.position.x to game.playerx+10 (or something)
  • FallingBoxStudiosFallingBoxStudios Freelance Graphic Designer Member Posts: 822
    edited September 2013
    @timolapre1998 I tried, and it did not work :(
  • KevinCrossKevinCross London, UKMember Posts: 1,894
    edited September 2013
    Did you set up two game attributes called playerX and playerY and constrain the players x and y position to those two attributes? What @timolapre1998 says is correct and is something I've done myself in the past.
Sign In or Register to comment.