Hello, I made an 8 direction action combat game that can jump for school assigment. I'm still relatively new to construct 2 and programming so I don't know what happened in the calculation, machine, arrangement or whatever it is.
For each character (There is only 2, player and enemy) I made a shadow, the shadow contain 8direction behavior.
In the shadow there is Instance Variable called 'altitude'. THe shadow is used to show character's position.
Then there is puppet object (marked as 'target' in the picture, I forgot to change the text), it position will be set to (shadow.X, shadow.Y-shadow.altitude).
There is event who manage the altitude with gravity and projectile speed. It goes like this:
if altitude > 0
altitude= altitude+projectile speed
projectile speed= projectile speed-gravity
else if altitude <=0
altitude= 0
projectile speed=0
I run this event every tick:
If altitude<=0 set maxSpd to 200 and set deceleration to 5000
else set maxSpd to 5000 and set deceleration to 0
so when the puppet on air, there is no deceleration caused by ground friction. And when character on the ground I don't need to deal with these acceleration and deceleration stuff. UHHH
And when attacking, it create an object (let's call it hitarea) with 'knockback' variable.
And when that object hit another character, It knock them back with the knockback variable using this:
On "hitarea" collision with "shadow"
set projectile speed to 10 (so it will throw to the air)
set Vector X to cos(hitarea.Angle)*knockback
set Vector Y to sin(hitarea.Angle)*knockback
What I expected is the character will thrown in to the air and knocked back for a distance flawlessly.
It should be like this:
Thrown in the Air, the altitude increased, deceleration changed to zero, knocked back with no deceleration
But what happened is: (I'm not certainly sure)
Thrown in the air, the altitude increased, knocked back and decelerate for very high value, deceleration changed to zero.
So it only knocked back a little.
I discovered by collide another hitarea with same knockback value when the character was in the air, It knocked back flawlessly like it expected to do. Or I might be wrong.
How do I make it change deceleration to zero first then knock back the character?
Maybe you can help me.
note:
I already put change deceleration to 0 in the middle like this:
On "hitarea" collision with "shadow"
set projectile speed to 10 (so it will throw to the air)
change shadow deceleration to 0
set Vector X to cos(hitarea.Angle)*knockback
set Vector Y to sin(hitarea.Angle)*knockback
But it still didn't work.