Help LinePick
Blitz3D Forums/Blitz3D Programming/Help LinePick
| ||
trampaON% = LinePick(EntityX(personaje\modelo%), EntityY(personaje\modelo%), EntityZ(personaje\modelo),0,-100,0) Hi, I've put a linepick in my character to detect when treading a bear trap, but this does not seem to work correctly, because if you come walking on the trap the linepick does not return a value, but if it comes leaping on the linepick if the trap returns the data. Any suggestions? |
| ||
Try this. Don't forget to set your pick line radius. Let me know if you don't understand the code.TFormVector 0,0,0,personaje\modelo%, 0 trampaON% = LinePick(EntityX(personaje\modelo%),EntityY(personaje\modelo%),EntityZ(personaje\modelo%),TFormedX(), TFormedY(), TFormedZ() ) If trampaON% > 0 do stuff EndIf |
| ||
Hi, No work.EntityPickMode trampa1\trampa%,2,1 Function MoverPersonaje%(controladorJugador.CController) TFormVector (0,0,0, personaje\modelo%,0) trampaON% = LinePick(EntityX(personaje\modelo%), EntityY(personaje\modelo%), EntityZ(personaje\modelo),TFormedX(), TFormedY(), TFormedZ(),1) If KeyDown(KEY_W%) velPersonaje# = 0.5 If MouseDown(2) = False Then btBodySetRotation ( controladorJugador\body%, 0, EntityYaw(camaraPrincipal\camara%), 0) RotateEntity( personaje\modelo%, 0, EntityYaw(camaraPrincipal\camara%), 0) End If ElseIf KeyDown(KEY_S%) velPersonaje# = 0.5 If MouseDown(2) = False Then btBodySetRotation ( controladorJugador\body%, 0, EntityYaw(camaraPrincipal\camara%)-180, 0) RotateEntity( personaje\modelo%, 0, EntityYaw(camaraPrincipal\camara%)-180, 0) End If End If btCControllerSetWalkDirection(controladorJugador\controlador,0,0,velPersonaje#,False) velPersonaje# = 0.0 If KeyDown(KEY_SPACE%) And Tecla_Espacio% = False Then btCControllerJump(controladorJugador\controlador%) Tecla_Espacio% = True ElseIf KeyDown(KEY_SPACE%) = False And Tecla_Espacio% = True Then Tecla_Espacio% = False EndIf If trampaON% > 0 End End Function |
| ||
Stayne's tformvector suggestion is pointless as it results in a pick vector of 0,0,0 which will never return a collision. As you are registering a collision while jumping it sounds like you need to start your linepick higher up on the Y axis before projecting the vector downwards. This is normal practice. Change the +25 to suit. trampaON% = LinePick(EntityX(personaje\modelo%), EntityY(personaje\modelo%)+25, EntityZ(personaje\modelo),0,-125,0) Stevie |
| ||
My bad for leaving out the length..but I thought you have to convert local to world vector and utilize the result. Or does linepick already do that? |
| ||
Because in this case the linepick does not need to be oriented depending on the camera/eyes orientation this example should work :EntityPickMode(BearTrapPickable,2) LinePick(entityx(characterfeet,true),entityY(characterfeet,true)+0.85,entityz(characterfeet,true),0,-100,0,0.25) ;0.85 corresponds to half the height of your character | 0.25 corresponds to the radius of your character PickedPickable = PickedEntity() If( PickedPickable <> 0 ) PickedName$ = EntityName(PickedPickable) If( PickedName = BearTrapName ) ;do something endif endif EntityPickMode(BearTrapPickable,0) See : (for oriented linepicks and to retrieve several kinds of entities in different lists with nameentity() entityname()) http://www.blitzbasic.com/codearcs/codearcs.php?code=3094 http://www.blitzbasic.com/codearcs/codearcs.php?code=3095 I also recommend to separate the pickables and the renderers so that the linepicks will take less mstime and be more precise. (on low tris meshes) |
| ||
Thanks You Stevie G, Work Perfect :)Function MoverPersonaje%(controladorJugador.CController) trampaON% = LinePick(EntityX(personaje\modelo%), EntityY(personaje\modelo%)+25, EntityZ(personaje\modelo),0,-25,0,3) If KeyDown(KEY_W%) velPersonaje# = 0.5 If MouseDown(2) = False Then btBodySetRotation ( controladorJugador\body%, 0, EntityYaw(camaraPrincipal\camara%), 0) RotateEntity( personaje\modelo%, 0, EntityYaw(camaraPrincipal\camara%), 0) End If ElseIf KeyDown(KEY_S%) velPersonaje# = 0.5 If MouseDown(2) = False Then btBodySetRotation ( controladorJugador\body%, 0, EntityYaw(camaraPrincipal\camara%)-180, 0) RotateEntity( personaje\modelo%, 0, EntityYaw(camaraPrincipal\camara%)-180, 0) End If End If btCControllerSetWalkDirection(controladorJugador\controlador,0,0,velPersonaje#,False) velPersonaje# = 0.0 If KeyDown(KEY_SPACE%) And Tecla_Espacio% = False Then btCControllerJump(controladorJugador\controlador%) Tecla_Espacio% = True ElseIf KeyDown(KEY_SPACE%) = False And Tecla_Espacio% = True Then Tecla_Espacio% = False EndIf End Function |