How do i make Sword attack behavior possible with 1 actor?

Raseru09

  • Posts: 22
I'm new at stencyl and i want to know how to make a side-scrolling sword attack behavior using only 1 actor with this animation present.

twotimingpete

  • *
  • Posts: 1667
think of it as being the same as making a gun behavior, only the bullet is invisible, it's probably bigger, and it doesn't move. it just appears for a split second and dies, and any enemy touching it is hurt.

if you need more detailed step by step help than that (how to spawn actors, for instance) you really should start with the basics and follow a tutorial or two.

Raseru09

  • Posts: 22
gee, thanks, i'll work on it. So i really have to use another actor?

twotimingpete

  • *
  • Posts: 1667
let me know if you have any more specific questions. :)

Raseru09

  • Posts: 22
2 actors, right?

twotimingpete

  • *
  • Posts: 1667
is there some reason you don't want to spawn a sensor actor to detect the hit? because that's the most common and direct way of doing it.

Raseru09

  • Posts: 22
no reason. i just didn't know it was actually impossible.

twotimingpete

  • *
  • Posts: 1667
it's not impossible at all. You could use regions, or add a new collision shape specific to that swinging animation and place it over the sword (you can make multiple regions per animation). You could also use coordinates to isolate an area of effect for being hit.

Spawning an actor is just the easiest way and the way I'd do it unless I hit some snag that made another method seem better.

Callan S

  • Posts: 147
The platforming demo has an example of a character jumping on goombas like mario, so he uses his body as a weapon. You might want to look at that, but make it only for collisions on the side the character is facing and only while the attack animation occurs.

twotimingpete

  • *
  • Posts: 1667
you could make it so the side of your character damages the enemy when it touches it during the time that it's doing an attack animation. I just don't know why you would ever want to do this. It sounds limiting to me.

With Stencyl you have a whole toolkit in front of you that enable you to do many things in many differnet ways. You could accomplish the same exact result in a huge number of different ways. My first instinct would be to spawn an actor for collision detection of the melee attack. If for some reason you don't want to do that, there are other ways, as I've laid out.

Raseru09

  • Posts: 22
I see, I guess I'll work on two actors.

Raseru09

  • Posts: 22
I still haven't Achieved this, can I use the region technique instead?

twotimingpete

  • *
  • Posts: 1667
what specifically are you having trouble with?

to speak as a general outline, what I'd do is spawn the collision sensor based upon the animation frame.

1) character switches to sword swing animation
2) when the correct frame is reached, spawn the sensor actor at the appropriate coordinate relative to the actor (so you'd spawn actor at x of self + offset number and y of self + offset number, the offset being what you use to tweak its location)
3) give the sensor actor a simple block or circle graphic and make it so it can't move, also set it to sensor and the appropriate collision group and so on. have it die after a very short time, after, say, .1 sec or less (depends on the animation though, I suppose)
4) tell the enemy that when it collides with that sensor, damage self (whatever you want your damage logic to be).

that's the general outline of how I'd approach it. is there anything specifically you're having trouble figuring out or need explained in more detail?

Raseru09

  • Posts: 22
I used Sidescroller sword attack behavior from Stencyl Forge, and it didn't work fine. I've also been trying now to spawn that other actor that damages enemies but it doesn't appear on the right place, and even so, my animation doesn't change.
so i kinda wanna ditch that behavior...
Thanks a lot, now I understand it a little bit more now..

Raseru09

  • Posts: 22
I guess i'll just make some kind of Slash special effect for the new actor.