I'm having issues with melee attack

1 favourites
  • 3 posts
From the Asset Store
Zombie attack is a survival game, where you have 2 types of games: Killer and survival.
  • Hey folks! I'm very new to using Construct 3 (I've had it about 3 months or so) and have been learning how to use it by making a simple platformer level from scratch.

    What I'm trying to do

    Currently, I'm trying to allow the Player to swing his sword in order to attack enemies. Here's what the Player Attack section of the event sheet looks like.

    As you can see, I have the platform behavior added to the PlayerBox object and created a separate Sprite called PlayerAnim which contains all my animations (walk, jump, attack, etc.) and is positioned to the PlayerBox on every tick.

    The idea is, I have a "Slash" sprite (which is a frame from the player_attack animation) created as an object which, on collision with an enemy sprite, does damage. I got this idea from the "Demonoire" project template that comes with Construct 3.

    The Problem

    1. The Slash sprite is way smaller than the PlayerAnim sprite despite the images being the same size. Ideally it would be the same size so it overlaps the PlayerAmin sprite perfectly. This way I can set the collision points on the sword only for the Slash sprite and the collision points for the player only on the PlayerAnim sprite.

    Currently I have to walk to the middle of an enemy in order to kill him.

    2. The Slash sprite sticks around if I attack while jumping/moving, because it's set to be destroyed when the "attack_sword" animation is finished player. I'm not sure how to fix this.

    3. I disabled player movement during the attack events, but for some reason I'm still able to move the player while attack (fixing this might make #2 in this list moot.)

    And that's it!

    Here's a link to the .c3p file

    drive.google.com/file/d/1GWvo4-X4L1GgZ2R605EUHhERuf-IyraO/view

    I hope this isn't too much to ask on this forum, but I've spend ~6 hours trying to resolve this issue, looked at other Construct templates, and even purchased a Construct platformer template from scirra.com but for some reason I cannot replicate these results when create the project from scratch myself.

    I would really appreciate any solutions you can provide. I really would like to keep working and learning and this hurdle is becoming a big blocker.

    Thank you :)

    Tagged:

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Welcome! I will just explain a few things that I saw.

    The movement controls in your group do not do much, the condition should be 'key is down' rather than 'on key pressed' which is a trigger one event. The platform behaviour has something called 'default controls' which is where the arrow keys work for moving. Because this is enabled it is actually this which is working for the movement and not your events, which is why disabling them has no effect. If you untick 'default controls' on the platform behaviour you can start to simulate your own controls.

    Slash is created at its size in the editor around 24x24 whereas the player object has been adjusted in the layout to be a bit larger so this is why the player is larger than the slash object. You need to adjust its size in the editor or when the object is created. Also you are trying to set an animation from another object, you cannot do this and the animation must be on the slash object.

  • Welcome! I will just explain a few things that I saw.

    Thank you for taking the time to review my issue and help me out! I definitely did not realize the significance of 'on key pressed' vs 'down' and the default enable of platform behavior controls. I also didn't know a sprite could be one size in the animations editor and another in the layout.

    I was able to make the changes you suggested and everything is working perfectly. Thanks for the welcome and, again, for helping me through this block so I can continue to learn more about what Construct can do without this previous puzzler nagging me :D

    Have a nice Monday!

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