1
0
Fork 0

Balance out collision forces for mobs

This commit is contained in:
jordan4ibanez 2021-04-17 17:00:34 -04:00
parent 3cf263d292
commit e2987245fd
2 changed files with 6 additions and 7 deletions

View File

@ -9,12 +9,6 @@ local vector_new = vector.new
local minetest_dir_to_yaw = minetest.dir_to_yaw local minetest_dir_to_yaw = minetest.dir_to_yaw
-- simple degrees calculation
local degrees = function(yaw)
return(yaw*180.0/math_pi)
end
-- set defined animation -- set defined animation
mobs.set_mob_animation = function(self, anim, fixed_frame) mobs.set_mob_animation = function(self, anim, fixed_frame)

View File

@ -1,6 +1,7 @@
local minetest_get_objects_inside_radius = minetest.get_objects_inside_radius local minetest_get_objects_inside_radius = minetest.get_objects_inside_radius
local math_random = math.random local math_random = math.random
local vector_multiply = vector.multiply
local integer_test = {-1,1} local integer_test = {-1,1}
@ -74,9 +75,13 @@ mobs.collision = function(self)
local vel1 = vector.multiply(velocity, -1.5) local vel1 = vector.multiply(velocity, -1.5)
local vel2 = vector.multiply(velocity, 1.5) local vel2 = vector.multiply(velocity, 1.5)
vel1 = vector.multiply(vel1, force) vel1 = vector.multiply(vel1, force * 10)
vel2 = vector.multiply(vel2, force) vel2 = vector.multiply(vel2, force)
if object:is_player() then
vel2 = vector_multiply(vel2, 2.5)
end
self.object:add_velocity(vel1) self.object:add_velocity(vel1)
object:add_velocity(vel2) object:add_velocity(vel2)
end end