What force to apply to the smash in order to keep the same distance between my character and enemy ?
Hey, I'm creating a platform game called "The Fur in Me". In order to defeat your enemies, you have to jump on them, at the same time that you change your color to match your enemies's color.
Notes : The player is a rigidbody, uses AddForce to jump. The enemy is not a rigidbody, and moves with translate.
Image above : Because the enemy has 1hp , everything works fine.
Image below :The problem starts when I add enemies that have more than one hp.
The player is a rigidbody. When the player smashes the enemy (or jumps), I use AddForce to propel him up. Because AddForce has a fixed value and the enemy is moving up, there is not enough distance to change colors in time. How do I guarantee that the character's max distance to the enemy remains the same ?
I think I have to change the AddForce value according to the y value of the enemy's velocity vector.
I tried to use the equations of vertical projectile motion to solve this issue but failed miserably lol
Any ideas ?
Ps : Sorry for the bad gif quality and frame cutting, still need to learn how to optimize gifs better.