The Predict Path Projectile function offered by BP can only simulate paths with gravity on the Z-axis. But i wanna make it like in Angry Birds Space version, where the path predicted will be affected by gravity towards the center of the planet, so the Predict Path Projectile will be ineffective. How to realize this effect in BP?
This is pretty “math heavy” stuff compared to other game development stuff.
You can use a custom blueprint node in Unreal Engine that calculates the gravity vector based on the current position of the projectile and the center of the planet. Basically, calculate the gravity vector based on the current position of the projectile and the center of the planet. You can use the following formula to calculate the gravity vector:
gravity = - G * (projectile_position - planet_center) / |projectile_position - planet_center|^2
I used the universal gravitation law from Newton, so there has perhaps been other discoveries to improve the formula. In essence, the G is the gravitational constant, projectile_position is the current position of the projectile, planet_center is the center of the planet, and |.| denotes the Euclidean norm.
Thank u so much for your reply ! Actually i’ve done the maths of Newton Laws and used AddForce to drag an actor. But the question at present is how to realize the function showing the predicted path of an actor affected by gravity and bounces, which Predict Path Projectile dealed with well, but lacking generality in different gravity scenarios. I’ve tried to DIY but that’s a bit hard for me
Hey @Cinderquill2002
you could create a pseudo physical simulation with some pre-generated points which are then used by a ball/projectile to set its world location.
503|PathPrediction.zip (85.2 KB)
Thank you so much! This is awesome and im trying to understand
Hi there @Cinderquill2002, hope you’re well!
This topic has been moved from International to Programming & Scripting: Blueprint.
When posting, please review the categories to ensure your topic is posted in the most relevant space.
Thanks and happy developing!
Yo! OMG this is so great! Thank you so much. Really helped me out.