How could we make a Box trigger in blitz? Because if we use a collision box, there will a collision. I just want to know if the plyer is inside a Box.
Trigger
Blitz3D Forums/Blitz3D Programming/Trigger You will probably need to make your own position check, If the box is not rotated in too many dimensions, this shouldn't be that hard.
The code below should get you started. I haven't tested it, though, so it may not work as is. I've used 'Then If' instead of 'And' so that the test will abort early if any of the checks fail (Using 'And' would cause the entire series of checks to be tested even if an early check failed).
If the range box is rotated relative to global space (and assuming it has a pivot or some other type of entity that you can use as a reference which is axially aligned in its local space) then you can map the centerpoint of your player to the range box's local space, using 'TFormPoint', before doing your range-checking.
If EntityX#( player ) < high_x# Then If EntityX#() > low_x# Then If EntityY#() < high_y# Then If EntityY#() > low_y# Then If EntityZ#() < high_z# Then If EntityZ#() > low_z# ; Player's centerpoint is inside box. EndIf
If the range box is rotated relative to global space (and assuming it has a pivot or some other type of entity that you can use as a reference which is axially aligned in its local space) then you can map the centerpoint of your player to the range box's local space, using 'TFormPoint', before doing your range-checking.
TFormPoint EntityX#( player ), EntityY#( player ), EntityZ#( player ), 0, range_check_reference_entity If TFormedX() < high_x# Then If TFormedX() > low_x# Then If TFormedY() < high_y# Then If TFormedY() > low_y# Then If TFormedZ() < high_z# Then If TFormedZ() > low_z# ; Player's centerpoint is inside box. EndIf
Assuming your in need of a simple box trigger with no regard to orientation. Here are
3 box collision check algos
I recommend cascading the condition check for speed.
3 box collision check algos
If playerx<boxmaxx And playerx>boxminx If playery<boxmaxy And playery>boxminy if playerz<boxmaxz And playerz>boxminz Return True Endif EndIf EndIf If playerx<boxx+boxwidth And playerx>boxx If playery<boxy+boxheight And playery>boxy if playerz<boxz+boxdepth And playerz>boxz Return True Endif EndIf EndIf If playerx<boxx+boxhalfwidth And playerx>boxx-boxhalfwidth If playery<boxy+boxhalfheight And playery>boxy-boxhalfheight if playerz<boxz+boxhalfdepth And playerz>boxz-boxhalfdepth Return True Endif EndIf EndIf
I recommend cascading the condition check for speed.