YouGroove Posted August 14, 2014 Share Posted August 14, 2014 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) Quote Stop toying and make games Link to comment Share on other sites More sharing options...
macklebee Posted August 14, 2014 Share Posted August 14, 2014 see the example script posted here: http://www.leadwerks.com/werkspace/topic/10274-world-pick-collision-type-doesnt-work/#entry75890 Quote 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 More sharing options...
YouGroove Posted August 14, 2014 Author Share Posted August 14, 2014 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 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 Quote Stop toying and make games Link to comment Share on other sites More sharing options...
macklebee Posted August 14, 2014 Share Posted August 14, 2014 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. 1 Quote 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 More sharing options...
YouGroove Posted August 14, 2014 Author Share Posted August 14, 2014 Thanks a lot. Until in all Lua code i written , i always used GetPosition(false) thinking it was Global but that's the inverse and it's problematic with child objects. Quote Stop toying and make games Link to comment Share on other sites More sharing options...
macklebee Posted August 14, 2014 Share Posted August 14, 2014 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. 1 Quote 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 More sharing options...
Recommended Posts
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.