Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / character on matrix

Author
Message
helpme
20
Years of Service
User Offline
Joined: 28th Jan 2006
Location:
Posted: 2nd Jul 2007 09:36
How can I detect whether the character is on the matrix? The location of the matrix may change so I can't use static values.
Latch
19
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 2nd Jul 2007 13:34
When you create your matrix(ces), keep track of the x and z size as well as the tile size in an array or variables.

You can reference the matrix position with the MATRIX POSITION X() Y, and Z commands. Once you have the position, you use your x and z size to determine the offset. Once you have the offsets in the x and z directions in relation to the size, you can determine the bounds of the matrix in wrold space. If your character moves beyond those bounds, they are off of the matrix.

For example, if you created a 1000x1000 25x25 tile matrix, you know that minX=0 maxX=1000 and minZ=0 maxZ=1000. If you changed the position of the matrix and then you use MATRIX POSITION X(matrix number) and you get back 500, you know the x direction is offset by 500 units so minX=500 and maxX becomes 1500. If your character's x position was beyond those boundaries, they would be off of the matrix. If they are within those boundaries, they are on the matrix.

Enjoy your day.
TDK
Retired Moderator
23
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 2nd Jul 2007 16:05
To add to that, Get Ground Height allows you to set the characters Y position on the matrix - though the value returned does NOT take into account that the matrix is not at 0,0,0.

If you've positioned the matrix somewhere else, then you have to allow for the offset in Get Ground Height.

There's also a slightly more complicated method you can use - always have your character at X=0 Z=0 and move the matrix underneath it to make it look like the character is moving across it. This uses a combination of Position Matrix and Shift Matrix to achieve the effect.

TDK_Man

Login to post a reply

Server time is: 2026-07-06 00:44:13
Your offset time is: 2026-07-06 00:44:13