Is there a way to check the distance between 2 actors?
Shanesta
Member Posts: 63
I'm making a shooting game, and I really need to be able to tell the distance between 2 actors for scoring purposes, or per pixel collision.
Is there a way to do this?
Thx
Is there a way to do this?
Thx
Comments
Not sure about the other thing!
Sorry!
QS
Dr. Sam Beckett never returned home...
Twitter: https://twitter.com/Quantum_Sheep
Web: https://quantumsheep.itch.io
http://en.wikipedia.org/wiki/Pythagorean_theorem
You'll need to set up some global attributes to contain the X/Y position of the target when it is struck. And another game attribute signifying that you have struck the target.
Once the target is hit, the target should change those 3 game attributes with its position and make true the attribute showing that it has been struck.
Once your firing actor sees that the target has been struck via the game attribute, use Pythagorean theorem with the targets position and the firing actor's position to find the sides of the right triangle.
How do I enter the expression, I don't see squared under the function dropdown?
BTW , thx for you help man!
See that link for doing squared and square root.
game.Distance = (((game.TargetPosX-game.ShotPosX)^2)+((game.TargetPosY-game.ShotPosY)^2)))^(1/2)
Made a Change Attribute actor, and in change attribute, I put game.Distance, and on the right side I put...
(((game.TargetPosX-game.ShotPosX)^2)+((game.TargetPosY-game.ShotPosY)^2)))^(1/2)
It does not work for me, the screen is black when I run it.
Any idea what is going wrong? Have you actually tried it?
This is an extremely common function, I'm surprised there isn't a Behavior for it.
Thank man!
Thx again for your help CodeMonkey!