I'm making some bullets that home in on enemies for a game, and i wanted it so when they are about 50 pixels away from and enemy, they will chase it. Problem is, theres no angle calculator for MMF2 and i can't quite get the distance formula to work for me (maybe a little help with that?) so if anyone can help or has any ideas, I'd really appreciate it.
"Actually sir, we found a tiny unicorn in your exhaust. It was jumping around poking holes in your gas tank." "Oh thank you I did not know that. A tiny unicorn? Wow."
DaVince This fool just HAD to have a custom rating
You could also do: when the x of the bullet > the x of the enemy - 50 AND when the bullet x < enemy x + 50 AND these two for the Y, toggle a flag that makes the bullet chase the enemy.
You can also make your expressions a little tidier by using "pow" to raise the distances to the second power.
You just have to remember that its syntax isn't like "pow(x,y)", but rather "x pow y".
X Power Y = X*X*...*X }Y times
e.g. 3 pow 4 = 3*3*3*3, 7 pow 2 = 7*7
Squarte of X = Y only if Y*Y = X
e.g. Sqrt 4 = 2 cause 2*2=4, Sqrt 25 = 5 cause 5*5 = 25
Now you understand it?
;]
Deleted User
24th August, 2006 at 12:18:25 -
Yeah, thanks alot.
Now it all makes sense.
DaVince This fool just HAD to have a custom rating
Registered 04/09/2004
Points 7998
24th August, 2006 at 15:45:45 -
Squarte? Square root.
Pow is power. Like 2^5 (or 2 pow 5) is 2*2*2*2*2.
you could also do 2^(1/5), to get the 5th root, could you not?
I've never tried this... Someone try it and tell me
(Also might consider trying a^(x/y) i.e 2^(3/2) to give the square root of 2 cubed... I've never tried it in mmf, if it works it could be useful for saving on coding if it were ever used... not useful in this situation though, as it has to be the square root((X difference)² + (Y difference)²))
You could also get the angle using tan (y difference/x difference) but i think MMF has tan angles in radians... easy to convert to degrees though, (1 radian = 180/pi degrees)
Try using the advanced direction object?
It was converted to MMF2 and can find the distance between two points (if that is what you want - I haven't read the post fully to be honest)
You couldn't get distance in KnP since it didn't have an advanced expression editor nor extension support... The closest would be to get the difference in X or Y position...
But it was like 5 years since i last used KnP so i don't remember that well
ORRRR, you could judt make a circle radius 50, have it invisible, and its always attached to center of the bullet, then when it touches or overlaps the character, have it chase him
angle calculator hasnt been ported to mmf2 yet (at least i think) and the distance formula I tried did look like something Radix did although i probably ended up typing something in wrong cuz it didnt work. i'll try again and let you all know, and thanks for all the help
"Actually sir, we found a tiny unicorn in your exhaust. It was jumping around poking holes in your gas tank." "Oh thank you I did not know that. A tiny unicorn? Wow."
thanks for the heads up on that extension flava, it seems when i read this the first time i must've skipped right past your post lol.
"Actually sir, we found a tiny unicorn in your exhaust. It was jumping around poking holes in your gas tank." "Oh thank you I did not know that. A tiny unicorn? Wow."
You couldn't get distance in KnP since it didn't have an advanced expression editor nor extension support... The closest would be to get the difference in X or Y position...
Fail.
The only limitation is that you have to use alt values instead of brackets and you're finding the square of the distance, not the distance itself.