How can I make a swing attack like idoz?

S

SirClou

Guest
Hello! Can someone help me with creating an attack system like in this video by idoz?

I mean when he moves his mouse, the weapon moves with it, but with an off axis. and when he attacks, it swings smoothly and swings back. Can somebody help me with creating this?
 
S

SirClou

Guest
Thanks for the quick answer though I already know how to make a circular motion around the player. The problem is: I was searching for an offset, where when I am on top of the screen I have for example an image angle of 110, and when I am on the bottom of the screen i have an angle of 45. Obviously if I use the mouse as an indicator I will change my sword angle by 180, but I want to change it only by 65.
 
S

SirClou

Guest
I dont really want to clamp the range, but more or less dont move the angle 1 - 1 (if i move my direction aspect mouse-object position, i want to move less the angle)
So: if I for example move 1 degree mouse-object angle, I want to move my sword by .5 degree for example.
 
S

SirClou

Guest
I said this. Perhaps you're just not familiar with proportions? It's also called "multiplication". In short, (amount of in-game movement) = (amount of mouse movement) * (some factor).
The problem with that is that if I reach for example the point 350 and multiply it by 1.2 it will jump to the value 12 for example.
 

FrostyCat

Redemption Seeker
You should learn the Zeno's Tween book line.

In each of the following, f is a factor between 0 and 1, and tolerance is a cutoff under which the movement jumps straight to the target (usually 1 for geometric applications).

Linear (normal)
GML:
var diff = target-current;
current = (abs(diff) <= tolerance) ? target : (current+f*diff);
Angular (closest angular approach)
GML:
var diff = angle_difference(target, current);
current = (abs(diff) <= tolerance) ? target : (current+f*diff);
 

Nidoking

Member
The problem with that is that if I reach for example the point 350 and multiply it by 1.2 it will jump to the value 12 for example.
Why are you multiplying by a number greater than one if you're trying to reduce the sweep? Your example was that you wanted half of the movement. Half. That's .5. You put .5 right there in your own post. Why the heck are you complaining about what happens if you use 1.2? Where did you get 1.2 from anyway?
 
S

SirClou

Guest
the problem is it happens with 0.5 also... If you come to an image angle of 350 and then multiply by .5 you get an angle of 175. If you are going on the upper side of the screen you will have an angle between 0 and 90, so if I multiply 10 by .5 I get an angle of 5. See your comment doesnt make any sense
 

FrostyCat

Redemption Seeker
the problem is it happens with 0.5 also... If you come to an image angle of 350 and then multiply by .5 you get an angle of 175. If you are going on the upper side of the screen you will have an angle between 0 and 90, so if I multiply 10 by .5 I get an angle of 5. See your comment doesnt make any sense
It makes perfect sense once you realize that "amount of mouse movement" is NOT the same as "mouse position". Nidoking is telling you to multiply the difference, not the current amount.

If the current angle is 60 and the target angle is 20, then the angle difference is -40. You multiply this by 0.5 to get -20. Then you change the current angle by -20 to get 40, which is the expected movement.

If the current angle is 350 and the target angle is 10, then the angle difference is 20. You multiply this by 0.5 to get 10. Then you change the current angle by 10 to get 360, which is the expected movement.

Read my response again and think over how it works.
 

Nidoking

Member
Or, determine your input_min and input_max, as well as your output_min and output_max. These are the acceptable ranges for the angles. Then, (input_angle - input_min) / (input_max - input_min) = (output_angle - output_min) / (output_max - output_min). You know, proportions. The rest is algebra. You can do some algebra, I hope.
 
Top