Jump to content

[Solved] Question about Script:Collision


tipforeveryone
 Share

Recommended Posts

I can use a box with Collision Type = Trigger to detect player

 

function Script:Collision(entity,position,normal,speed)
self.playerInside = true
end

 

But I can't figure out how to execute when player NOT collides this box

 

something likes

 

function Script:Collision(entity,position,normal,speed)
if entity == player then
self.playerInside = true
else
self.playerInside = false --how can I do this :"D
end
end

Link to comment
Share on other sites

Generally the way ppl do this is by checking the entities "name" key.

 

If entity:GetKeyValue("name") == "player" then

else

end

 

 

Then in whatever script you have attached to your player you set the name key to "player". If you are using the player script that comes with le I think this is already set for you.

  • Like 1
Link to comment
Share on other sites

This does not work smile.png

 

I try

function Script:Collision(entity,position,normal,speed)
if entity:GetKeyValue("name") == "PlayerControl" then
System:Print("hit")
else
System:Print("no hit")
end
end

 

Then there is no "no hit" in output when player is outside of trigger box, of course it will display "hit" when player step inside the box. I want to do something when player step out or out side triggerbox.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...