Linepick collision

Blitz3D Forums/Blitz3D Programming/Linepick collision

Naughty Alien(Posted 2007) [#1]
..I would like to see some nice example of use Linepick for collisions with terrain or mesh level geometry since I am not understanding exactly this linepick thingy regarding parameters I have to provide for this command...anyone can post some nice example code with explanation regarding Linepick's parameters actually..


Stevie G(Posted 2007) [#2]
Well it's quite straightforward really.

The first set of params specifiy the starting point of the line pick and it's important to note that the second set are the vector to the end point, not the end point itself.

e.g.

LinePick 0,-10, -50 , 0,100,60

Will check picks between a line from 0,-10,-50 to 0,90,10.

Stevie


Moraldi(Posted 2007) [#3]
There is another example (with pseudo code):
If meshmodel moves front
 LinePick(EntityX(meshmodel), EntityY(meshmodel), EntityZ(meshmodel)+dz
if meshmodel moves back
 LinePick(EntityX(meshmodel), EntityY(meshmodel), EntityZ(meshmodel)-dz
if PickedNY(() < 0.85 then StopMeshModel()
.
.
.
etc

You can experiment with 0.85 and dz
I use the same method on my Xplorer game I am working on. Take a look it works great


John Blackledge(Posted 2007) [#4]
Moraldi, I think your codes lines got clipped. Try again.


Moraldi(Posted 2007) [#5]
No, not clipped, I was just very harry
If meshmodel moves front
 LinePick(EntityX(meshmodel), EntityY(meshmodel), EntityZ(meshmodel)+dz
Endif
if meshmodel moves back
 LinePick(EntityX(meshmodel), EntityY(meshmodel), EntityZ(meshmodel)-dz
endif
if PickedNY(() < 0.85 then StopMeshModel()
.
.
.
etc

Now its correct and more clear


Stevie G(Posted 2007) [#6]
Moraldi,

As John is pointing out, your LinePicks don't have a pick direction vector so will give you an error on compile.

Stevie


Moraldi(Posted 2007) [#7]
Oh guys, I am very sorry (I am laughing with my self, here in Greece we say that when a man makes the same mistake for a second time then he is not a wise man...). Here we are:
If meshmodel is onground

  maxradius = Max(meshmodel_collision_xradius, meshmodel_collision_yradius)
  If meshmodel moves front
   LinePick(EntityX(meshmodel), EntityY(meshmodel), EntityZ(meshmodel)+dz, 0, -2*MeshHeight(meshmodel), 0, maxradius)
  Endif
  if meshmodel moves back
   LinePick(EntityX(meshmodel), EntityY(meshmodel), EntityZ(meshmodel)-dz, 0, -2*MeshHeight(meshmodel), 0, maxradius)
  endif
if PickedNY(() < 0.85 then StopMeshModel()

endif
.
.
.
etc


No comments...