::UPDATE, HERE'S THE SOURCE CODE:: controls are mouse to aim and left click to u-turn
sync on
sync rate 20
hide mouse
`This is the ship and the cursor, respectively```````
make object cube 1,15
color object 1,RGB(255,255,0)
make object cone 2,50
xrotate object 2,90 : fix object pivot 2
scale object 2,150,100,300
position object 2,200,0,400
make matrix 1,1000,10000,10,10
position matrix 1,-500,-320,0
`These are the variables`````````````````````````````
```sens# is the control sensetivity``````````````````
```speed# is the craft's speed```````````````````````
```flow# is the direction you face, it is 1 or -1````
```UTURN# is the variable for whether or not a Uturn is active````````
```UTURN2# is the Uturn action timer``````````````````````````````````
```the tempcam# variables are where the camera must stay put``````````
ax#=0
ay#=0
az#=0
sens#=5
speed#=32
flow#=1
UTURN#=0
UTURN2#=0
tempcamx2#=0
tempcamy2#=0
tempcamz2#=0
position mouse 320,240
`Commence do commands````````````````````````````````
do
move object 1,speed#
ax#=object position x(1)
ay#=object position y(1)
az#=object position z(1)
`positioning and aiming the ship object, cursor object, and backdrop object`
if uturn#=0 then position object 2,((sens#)*(object position x(2))+ax#)/(sens#+1),((sens#)*(object position y(2))+ay#)/(sens#+1),az#-flow#*200
if uturn#>0 then move object 2,speed#
point object 2, (ax#), (ay#), az#
zrotate object 2,object angle z(1)
if uturn#=0 or uturn#>1 then set camera to follow ((sens#*object position x(2))+ax#)/(sens#+1),((sens#*object position y(2))+ay#)/(sens#+1),(((sens#*object position z(2))+az#)/(sens#+1)-(4*power#*boosted#)+(power#*braked#)/4),0,flow#*400,ay#/2+30,1,0
`FPS and Object 1(cursor)'s angle variables, printed to the screen```````````````
set cursor 0,0
print screen fps()
print object angle x(1)
print object angle y(1)
print object angle z(1)
`The controls`````````````````````````````````````
IF UTURN#=0
position object 1,flow#*(mousex()-320),(mousey()-240)*-1,az#
ENDIF
`left click to do a uturn`
if mouseclick()=1 then uturn#=5
```STEP 1 of Uturn, set timer, speed, and move to step 2```
if uturn#=5
speed#=16
uturn2#=100
uturn#=4
endif
`````counting down the timer variable`````
if uturn#>0 then uturn2#=uturn2#-1
```STEP 2, move to step 3 if timer reaches 75```
if uturn2#<75 and uturn#=4 then uturn#=3
```STEP 3, begin the turn around```
if uturn#=3
if flow#>0 then pitch object up 1,5
if flow#<0 then pitch object up 1,5
endif
````Make the cursor and the ship be the same angle````
if uturn#>0 and uturn#<4 then xrotate object 2,object angle x(1)
```Making the cursor face forwards for the correct flow#```
if uturn#>0 and uturn#<4
if flow#=1 then yrotate object 2,0
if flow#=-1 then yrotate object 2,180
endif
```STEP 4, stop the camera, keep it stopped, and rotate the ship upright```
if object angle x(1)<180 and uturn#=3 then uturn#=2 : tempcamx2#=camera position x() : tempcamy2#=camera position y(): tempcamz2#=camera position z()
if uturn#<3 and uturn#>0 then position camera tempcamx2#,tempcamy2#,tempcamz2#
if uturn#=2 then roll object left 1,5
```move ship and cursor to their positions for flying by the camera```
if uturn#=2 then position object 2,object position x(2),object position y(2)-1,object position z(2)
if uturn#=2 then position object 1,object position x(2),object position y(2)-1,object position z(2)-flow#*200
```STEP 5, complete uprighting```
if uturn#=2
if object angle z(1) <180 then uturn#=1
endif
```Correctly rotate/position ship/cursor and finish uturn after timer's up```
if uturn2#<1 and uturn#=1
uturn#=0
xrotate object 1,0
xrotate object 2,0
yrotate object 1,(flow#+1)*90
yrotate object 2,(flow#+1)*90
zrotate object 1,0
zrotate object 2,0
position object 2,ax#,ay#,az#-flow#*200
if flow#<1 then flow#=1 else flow#=-1
position mouse flow#*(object position x(1)-320),(object position y(1)-240)*-1
endif
sync
loop
I've always had this problem with making an object point at a position behind it, but I just can't figure out a way to make it work this time.
So, I've got an on rails game( moves you straight forwards while you aim the gun on a 2d plain) which has the ability to face backwards( in case you passed an enemy, you can still shoot them down before they get you). I have it set up so that object position 1 x and y = mouse position x and y -320 and -240 respectively. This makes it so that it goes to the farthest corner when your mouse is at position 0,0, and the default start position for the mouse is( obviously) 320, 240, making the default starting position for object 1 be 0,0,400.
As shown above, I have object 1 automatically Z positioned at 400, and when you press the turn around button, it goes through a fancy animation and ultimately your gun's rotation angles are 0,180, and 0, with object 1 being on a new set of commands. This command set has it's Z position be -400, it's X is -1*(mouse x - 320) and it's Y is (mouse Y - 240). It makes sure to correct the object angle so that it's pointing the right way in terms of X, but the Y the gun's always at an inverted angle. Do any of you know what the problem is? It's just using the simple "point at position in space" command, so that the gun points at the object that's at the right mouse position.
Pineapple juice, the best drink ever made.