In order to play different sounds when walls or spaceships are passing by the player, I'm trying to retrieve what kind of model is passing around.
I made this function (using ZgeBullet), that fire rays to test if models are passing around the player.
Here's a striped down example for detecting objects on the left side and playing a sound:
Code: Select all
xptr pointer = zbtRayTest(PlayerShip.Position.X, PlayerShip.Position.Y, PlayerShip.Position.Z,
PlayerShip.Position.X - 20, PlayerShip.Position.Y, PlayerShip.Position.Z);
if (pointer != null) playSound();
Code: Select all
xptr pointer = zbtRayTest(PlayerShip.Position.X, PlayerShip.Position.Y, PlayerShip.Position.Z,
PlayerShip.Position.X - 20, PlayerShip.Position.Y, PlayerShip.Position.Z);
if (pointer != null)
{
model m = zbtGetUserModel(pointer); // This is working nicely
if (m.PlaySound == 1) playSound(); // PlaySound is an Int in Model Obstacle, as an example, but it crashes. And it will not work with Enemy Models...
trace(intToStr(m.Category)); // It crashes
trace(m.Name); // I also tried to retrieve m.Name, but this doesn't seem to exist...
}