Need help with some math logic
-
Im trying to create a near miss logic. Basically i have an item falling from the sky. If it misses the player by inches i want them to be rewarded for it by showing a text saying something like “near miss +2 points”. Ive tried a few approach but my math sucks when it comes to these things. What i tried so far was getting position of object a and object b. Then used an if statement saying if object a x is = to object b x then show text bubble on object a with “near miss”. But i know for sure theres more to this equation.
-
You could just have an empty, transparent object with a collision larger than the player (representing the range of your “near miss) and have the “near miss” event trigger if the projectile or whatever stops colliding with the empty object and never collides with the player.
You could also do something simple and similar with calculate distance behaviors to set a radius.
There might be a more efficient way of doing this, but this is what I would do :)
-
@bosswave this is actually really smart. I just tried this out. I put an empty object and weld attached it yo my player. I changed the mass to zero. Im running into a problem however. If my main character bumps into an object it would rotate my character uncontrollably even when i have lock rotation off on both the main character and the weld attach object. Ive actually ran into this problem alot with weld attach. Any thoughts on how to fix this?
-
@bosswave im thinking this is a bug actually with weld attach. Lock rotation does not work with it.
-
Heres a simple project file. Hold and drag the green square. Its suppose to have rotation locked. But it doesnt. If you turn off the weld attach. Lock rotation will start working again.Weld attachment bug.tap
-
@SplitMindGaming try a pivot attach set to “pin”. That should (hopefully) fix it. I never have much luck with weld attach.
-
@bosswave yup that works. Thanks so much
-
@SplitMindGaming Any time :)