How do i speed check

Get help using Construct 2

» 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
118
S
32
G
51
Posts: 1,896
Reputation: 38,559

» 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
30
S
13
G
7
Posts: 740
Reputation: 8,099

» 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
69
S
22
G
14
Posts: 1,488
Reputation: 16,594

» Fri Jan 20, 2012 7:34 am

Yeah i use physics.
I must have add that code in condition editor or event editor?
B
118
S
32
G
51
Posts: 1,896
Reputation: 38,559

» 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
69
S
22
G
14
Posts: 1,488
Reputation: 16,594

» Fri Jan 20, 2012 10:49 am

thanks Yann i check this soon :)
B
118
S
32
G
51
Posts: 1,896
Reputation: 38,559

» Fri Jan 20, 2012 9:08 pm

Yann Thank you for good hint :)
B
118
S
32
G
51
Posts: 1,896
Reputation: 38,559

» 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

» Fri Jan 20, 2012 10:53 pm

This sounds professional :)
B
118
S
32
G
51
Posts: 1,896
Reputation: 38,559

» 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
69
S
22
G
14
Posts: 1,488
Reputation: 16,594

Next