I am stumped at the present moment. Perhaps some of you lua gods can help.
I am trying to get an entity (which is a SENT) to jump towards the player and keep jumping at the player.
I have the basic code to work out where the player is (Or at least I hope) and the radius of which the entity should be looking for a player, I can’t however get the prop to move towards the player.
I have tried ApplyForceOffset and SetVelocity and both have failed me. I get prop entitys flying all over the shop but never at players.
for k, v in pairs(player.GetHumans()) do if v:Alive() then local selfEntPos = phys:GetPos() phys:SetMass(50) local playerPos = v:GetPos() local entVector = phys:GetPos() - v:GetPos() if selfEntPos:Distance( playerPos ) < 5000 then phys:ApplyForceOffset( Vector(0,0,100) * math.random(0,50), entVector ) -- Apply a physics impulse to the physics object. end end end
Any help or pointers in the right direction would be greatly appreciated!