Thanks to fubarpk for pointing me in the right direction I now have basic collision in the game this will be added to as time goes on to be much more of a complete system.
Here is the function I created to see if my ship collides with a asteroid
:
function CheckCollision( object as integer, Range as float, Radius as float )
//this checks for colliion between an object with any other object and returns its id
local width as float
local height as float
local depth as float
local x as float
local y as float
local z as float
local object_hit as integer //this is who we have hit
x#=getObjectX(object)
y#=GetObjectY(object)
z#=getObjectZ(object)
SetObjectPosition( DummyObject, x, y, z )
SetObjectRotation( DummyObject, GetObjectAngleX( object ), GetObjectAngleY( object ), GetObjectAngleZ( object ) )
MoveObjectLocalZ( DummyObject, Range )
// calculate the start of the ray cast
start_x# = x#
start_y# = y#
start_z# = z#
// calculate the end of the ray cast
end_x# = GetObjectX( DummyObject )
end_y# = GetObjectY( DummyObject )
end_z# = GetObjectZ( DummyObject )
// determine which object has been hit
object_hit = ObjectSphereSlide(0,start_x#,start_y#,start_z#,end_x#,end_y#,end_z#, Radius )
endfunction object_hit
Basically it returns the object that you hit so you can work out what to do from there, it also checks a certain range and radius around the raycast this means that not only can I check a specific distant but also make sure that there isnt going to be any small discrepancies by sliding though polygons etc. Now that basic collision is in there I am going to return to backing objects and get that side of the game complete which should complete the sector visual effects and stuff so that I can move into NPCs and start making the game
-EdzUp