Page 1 of 1

### measure the vector X of a bullet

Posted: 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

### Re: measure the vector X of a bullet

Posted: 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

(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

### Re: measure the vector X of a bullet

Posted: 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?

### Re: measure the vector X of a bullet

Posted: 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

### Re: measure the vector X of a bullet

Posted: 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

### Re: measure the vector X of a bullet

Posted: Sun Apr 28, 2013 1:26 am
Work for me.

THANKS YOU!!!