Jump to content

Force applied to player doesn't affect player unless moving


Recommended Posts

I have an object that detonates, when it does it applies force to all objects within N range. It seems like the force isn't applied to the player unless it is moving. If the player is standing next to the object completely still when the force is applied, nothing happens. Once I move the mouse or press a directional button the force is applied and the player gets pushed. I am using the stock FPSPlayer script with the below snippet for applying the force. Does a player come to a resting state or something when they stop moving?

 

 

function Script:Detonate()
if self.enabled and self.state < 2 then
 self.state = 2
 local neighbors = GetEntityNeighbors(self.entity, self.radius, true)
 local self_pos = self.entity:GetPosition(true)

 local i = 1

 while neighbors[i] ~= nil do
  if type(neighbors[i].script.Detonate)=="function" then
   neighbors[i].script:Detonate()
  else

   local neighbor_pos = neighbors[i]:GetPosition(true)
   local dist = neighbor_pos - self_pos
   local force = self.force * (1 - (dist:Length() / self.radius))

   neighbors[i]:AddForce(dist:Normalize() * force)
  end

  i = i + 1
 end

 self.entity:Hide()
end
end

Link to comment
Share on other sites

I experienced a similar issue when testing my door (using the beta). If I stand in the path of the door and close it, if I remain perfectly still, it passes right thought me and the player does not move. As soon as I touch any movement control, I am instantly ejected away from the door. If I move in any way as the door hits me, I am shoved along with it as expected.

Link to comment
Share on other sites

Fixed. Anything for THFH.

 

I experienced a similar issue when testing my door (using the beta). If I stand in the path of the door and close it, if I remain perfectly still, it passes right thought me and the player does not move. As soon as I touch any movement control, I am instantly ejected away from the door. If I move in any way as the door hits me, I am shoved along with it as expected.

If you have another bug please create a thread along with an example map that produces the problem.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...