Do this first then this. Deceleration and whatnot

Get help using Construct 2

Post » Thu Jun 08, 2017 10:06 am

Image
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.
B
8
Posts: 10
Reputation: 322

Post » Thu Jun 08, 2017 11:59 am

Should share your project.

One thing is see is that the 'On "hitarea" collision with "shadow"' will mostly not trigger.
When you create the area, it is probably and mostly already overlapping one of the shadows.
Then there will no collision happen.
(i dont know if they are instances)

All the rest depends on your setup and the events.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Thu Jun 08, 2017 3:16 pm

here is the file:
dropbox.com/s/akm37pqe6ggsnnb/sendtak.capx?dl=0
(the forum wont allow me to post link)

I deleted most asset to make it lighter,.. but it still 2MB though.
The event I'm talking about is in the foeControl event sheet below "EXPERIMENTAL" comment.
the control is WASD and left click to attack. Shift to roll and dash, space to jump but you don't need that.

Try to slay the slime, when it's on air try to slay again. It will make a difference.

99Instances2Go wrote:Should share your project.

One thing is see is that the 'On "hitarea" collision with "shadow"' will mostly not trigger.
When you create the area, it is probably and mostly already overlapping one of the shadows.
Then there will no collision happen.
(i dont know if they are instances)

All the rest depends on your setup and the events.


The collision is happening. It's triggered already.
B
8
Posts: 10
Reputation: 322

Post » Thu Jun 08, 2017 8:59 pm

1/ if you set the deceleration to zero ... there is nothing that stops it ... it keeps going ..

(you do that also with the players shadow in event 55, i did't check further, also in that event ... facing is incorrect .. had to temper that event first to see whats happening with the foe's shadow)

2/ in event 9 you did't pick the correct foe's shadow, there is always a foe with alt = zero

3/ in event 9 .. an 'else' (else runs when the parent event did not run) ... an 'else' that is supposed to make another picklist .. MUST pick ....
So, this 'else' should be ....

Else
Alt =not zero <----- picks the others
___________ actions

4/ because you got to pick the right one, and that is key, i moved things to the collision event.

5/ I dont think that is exactly what you want, but it should have you going again. Mind the picking ! Keep in mind that the first condition (in a root event) picks from scratch and the follow sub/conditions only refine that picklist.

https://www.dropbox.com/s/1jgjvvbqfjozf ... .capx?dl=0

If this are your first steps in C2, i applaud you. Really. I would not have come this far at all.
Just ask if you have questions.

6/ user browser object to debug (open up the console in chrome to see it working)
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Thu Jun 08, 2017 9:19 pm

Adding ...

See it like this.

Deceleration = how many pixels / second it will slow down. 100 = in 1 second period it will subtract 100 pixels from the speed, with a min of zero.
Acceleration = how many pixels / second it will speed up. 100 = in 1 second period it will add 100 pixels to the speed, with a max of the max speed.

Situation 1/ Using the simulate controls, including 'stop'.
(key is down) Simulate > Acceleration kicks in (until max speed reached) .... (key released) Stop simulating > Deceleration kicks in.
The vectors are managed by the system.

Situation 2/ Setting the vectors yourself.
Acceleration is skipped. Deceleration kicks immediately in. (because there is no ongoing force no more)

So, i think you better keep the Deceleration constant, set in the properties.
Alter the (vector)speeds to your needs.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950


Return to How do I....?

Who is online

Users browsing this forum: guannstar, odiusfly and 25 guests