Hi, I could use some help with a little problem I'm having with rotation.
The problem is this: I have a model (a spaceship) and I need a way to check only the left and right side of the ship to see if it collides with another model or the environment.
I know how to raycast from the center of the spaceship to the left and right, but I need the ends of the raycasts to rotate with the spaceship. And, that is where the problem lies. I know there must be some formula to calculate, but its been way too long since I had maths, so I dont remember what it was.
So, when I rotate the spaceship (from the center) to the left/right, the endpoints of the raycasts both left and right, should rotate. Sorta like the moon around the earth.
Can someone help me with this?
this is the piece of code that does the controlling/rotation of the ship:
if leftkey()=1 then a#=wrapvalue(a#-3.0)
if rightkey()=1 then a#=wrapvalue(a#+3.0)
rem Update ship
y#=get terrain ground height(1,x#,z#)+260.0
position object 3,x#,y#,z#
yrotate object 3,a#
rem Position camera to the back of the ship
ca#=wrapvalue(curveangle(a#,ca#,9.0))
cx#=newxvalue(x#,wrapvalue(a#+180),300)
cz#=newzvalue(z#,wrapvalue(a#+180),300)
cy#=get terrain ground height(1,cx#,cz#)+350.0
position camera cx#,cy#,cz#
yrotate camera wrapvalue(ca#)
OldX# = object position X(3)
OldY# = object position Y(3)
OldZ# = object position Z(3)
XSL# = Object Position X(3)+100
YSL# = Object Position Y(3)
ZSL# = Object Position Z(3)
SHIPCollision_left = SC_RayCast(0,OldX#,OldY#,OldZ#,XSL#,YSL#,ZSL#,0)
Thanks in advance.
SLAYER RULES! YEAH, MAN!!