How do i speed check

Get help using Construct 2

Post » Thu Jan 19, 2012 10:16 pm

I must have a checker to speed of flying fireballs. How can i create condition-
when fireball impact with wall with low speed, fireball inflict 10-20 damage
when fireball impact with wall with medium speed fireball substract 21- 35 damage.

I have use angrynerds example in this tutorial i can set power of shotting projectiles from 0 to 100 power
B
93
S
19
G
34
Posts: 1,840
Reputation: 27,963

Post » Thu Jan 19, 2012 10:31 pm

Its all dependent on your current code and behaviors. what behavior is the fire ball using? if its using physics then you can get its velocity.
B
29
S
12
G
7
Posts: 740
Reputation: 7,839

Post » Thu Jan 19, 2012 11:42 pm

if you use Physics you can get the speed of an object like that

[code]distance(0,0,Sprite.Physics.VelocityX,Sprite.Physics.VelocityY)[/code]
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Fri Jan 20, 2012 7:34 am

Yeah i use physics.
I must have add that code in condition editor or event editor?
B
93
S
19
G
34
Posts: 1,840
Reputation: 27,963

Post » Fri Jan 20, 2012 10:42 am

What I wrote isn't a condition nor an action. It's an expression. Expression can be used anywhere. This one return the speed of your object, so if you want to compare speed you can use that in System: compare two values or if you want to use speed to calculate damage you can do a System: set damage to distance(0,0,Sprite.Physics.VelocityX,Sprite.Physics.VelocityY)*anyKindOfMultiplier
So yeah... you do what you want.
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Fri Jan 20, 2012 10:49 am

thanks Yann i check this soon :)
B
93
S
19
G
34
Posts: 1,840
Reputation: 27,963

Post » Fri Jan 20, 2012 9:08 pm

Yann Thank you for good hint :)
B
93
S
19
G
34
Posts: 1,840
Reputation: 27,963

Post » Fri Jan 20, 2012 10:29 pm

If you're confused about the distance expression..
another way of doing it is:

sqrt(sprite.Physics.VelocityX^2)+(sprite.physics.VelocityY^2)
because it's basically that.. maths thing.. you know.. working out the long side of a triangle and sh*t. yeah.

I don't think most people would have thought about using the distance expression... but hey it all works.keepee2012-01-20 22:29:34
B
28
S
8
G
1
Posts: 469
Reputation: 4,683

Post » Fri Jan 20, 2012 10:53 pm

This sounds professional :)
B
93
S
19
G
34
Posts: 1,840
Reputation: 27,963

Post » Sat Jan 21, 2012 4:31 am

By the way, talking of using function to do something they weren't meant to, you can do a :
[code]cos(angle(0,0,number,0))[/code]to get the sign of number.
Basically if the number is positive, the angle is 0 and if it's negative the angle is 180.
cos(0) = 1
cos(-180) = -1
you will have the equivalent of the sign() function in Construct ClassicYann2012-01-21 04:32:27
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Next

Return to How do I....?

Who is online

Users browsing this forum: Braus and 5 guests