Jump to content

How to lasers raycast detecting characters or Props


YouGroove
 Share

Recommended Posts

I need some raycast like moving lasers, i want it to detect if a character passes by them or if some crate would block them. How to make a working Raycast for lasers in LE3 ?

Does someone have some working example ? (i used pick method, but it don't detect anything)

Stop toying and make games

Link to comment
Share on other sites

Thanks macklebee.

(It's very informative for character collisions to work using meshes, this should be in some doc)

 

But i already had similar code for and remade a simple test level and the pick is always detecting something ? Can go crazy but i really don't find the problem laugh.png

 

I put a zip that contains "testPick.map" and the directory "Pick" to copy at base folder of "MyGame" LE3 project.

If you have time to test ?

pick.zip

post-3271-0-48204700-1408007317_thumb.jpg

Stop toying and make games

Link to comment
Share on other sites

There are two issues that prevent your pick from being successful.

1) The pickmode script is using the local position of entity p2 for the endpoint of the pick

self.posP2 = self.p2:GetPosition(false)

which wouldn't be an issue except that you parented entity p2 under entity p1. The world pick uses global positions. So you can either un-parent p2 in the scene panel or the better method would to use the global position of both p1 and p2 in your script.

self.posP1 = self.entity:GetPosition(true)

self.posP2 = self.p2:GetPosition(true)

 

2) The fpsplayer script sets the player's pickmode to 0. This makes it so it will be skipped in all pick tests. This was done so its own physics body wouldn't interfere with the picks it performs in the fpsplayer script. You can comment that line out and your script will detect the player, but the better way would be to turn off the player's pick mode just prior to its two picks and then turn it back on afterwards. Or rewrite the player's picks so it starts away from the player so its own body doesn't interfere.

  • Upvote 1

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

It's only problematic if you try to use a local position of a parented entity when you need a global position. If the entity doesn't have a parent then its local position is equal to its global position. Just have to be aware of what you need for the circumstance being performed.

  • Upvote 1

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

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...