measure the vector X of a bullet

Get help using Construct 2

Post » Sat Apr 27, 2013 11:36 pm

hello friends, I want to know how to get the vector X of a bullet

Example:

If bullet.vectorX > 10 (do something)
If bullet.vectorX < 10 (do other thing)

I do not get where to put this condition . thanks

Luis Molina
B
48
S
9
G
10
Posts: 200
Reputation: 8,258

Post » Sun Apr 28, 2013 12:10 am

I was unable to find it :/, I think you want to know the Sped on the X axis, with the minus if it goes to the left, we can recreate the expression should be okay too:

Sprite.Bullet.Speed and Sprite.Bullet.AngleOfMotion will help us

your VectorX is equal to:
(Sprite.Bullet.Speed * cos(Sprite.Bullet.AngleOfMotion))

and also VectorY is equal to:
(Sprite.Bullet.Speed * sin(Sprite.Bullet.AngleOfMotion))

Sprite is the name of your sprite

Tell me if I am wrongAphrodite2013-04-28 00:16:47
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
52
S
22
G
18
Posts: 2,122
Reputation: 17,093

Post » Sun Apr 28, 2013 12:44 am

Your theory is good but only good for a bullet traveling on a fixed path.
In my case I need to know which way (left or right). a bullet of fire like mario bros type when you get a flower.

my bullet is constantly changing angle while ground bounces.

Thank you.

someone else wants to contribute to my question?
B
48
S
9
G
10
Posts: 200
Reputation: 8,258

Post » Sun Apr 28, 2013 12:56 am

[QUOTE=luisgmolina] Your theory is good but only good for a bullet traveling on a fixed path.
In my case I need to know which way (left or right). a bullet of fire like mario bros type when you get a flower.
[/QUOTE]

when the path changes, the formula is still valid I guess, and the VectorX I wrote is a negative number when going to the left, a positive when going to the right , and 0 if not travelling on the X axis(since the cosinus can be negative or positive or equal to 0 with the angle)

but still, this is a tricky formula, and I'm pretty sure a more understandable method can be foundAphrodite2013-04-28 00:59:31
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
52
S
22
G
18
Posts: 2,122
Reputation: 17,093

Post » Sun Apr 28, 2013 1:22 am

I just want to know to which direction the bullet goes: left or right, I mean positive X or negative X

Left or Right
-X   or   +X

Thanks
B
48
S
9
G
10
Posts: 200
Reputation: 8,258

Post » Sun Apr 28, 2013 1:26 am

Work for me.

THANKS YOU!!!
B
48
S
9
G
10
Posts: 200
Reputation: 8,258


Return to How do I....?

Who is online

Users browsing this forum: plinkie and 16 guests