Posted April 15, 2020 by KJCostello
Hey guys!
Just wanted to give you all a quick look at one of the mechanics we are adding to help make the combat more dynamic and fun: knockback!
When starting to implement this feature, I took advantage of some preexisting code on the enemy script which detected when it collided with a players weapon. I then stored the location of the weapon and the enemy in order to calculate the vector between them and then simply moved the enemy along that vector direction.
Oh no! That's not right at all!
I accidentally set the vector to point from the enemy to the weapon instead of the other way around!
There, much better! A simple switcheroo and its all fixed.
Similar to damage, each weapon can be assigned a knockback force to determine how hard the enemy is sent flying, as well as a knockback time which determines how long it will be under that force.
Separating the two variables for manipulation can actually create some really cool effects for the weapons such as a slowing effect. If you place a small amount of force (that the enemies movement speed can overcome) over a long period of time (say three seconds) your newly made Hammer of Frost will temporarily slow every enemy it hits!
Thats all for now! Thanks for tuning in guys and be sure to look out for new posts in the future!