Have a space flight sim, When a target/object is selected(12 for example) and letter 'I' is pressed, I want my ship to turn towards the target at it's present speed until i let off the "I" key. I have it working using the following simple code, but it jumps too sharply towards the target. Object 10 is my target, 12 is the target i'm closing in on.
Target(temp):
input target
return
Intercept:
point object 10,object position x(12),object position y(12),object position z(12)
endif
return
If possible I would like it to bank/tilt and turn at the same rate it does when I navigate manually, but i'm not clear on how to do this exactly since there are unknowns. Here is the code I use to manually navigate my ship...
`SPEED control
if shiftkey()=1 then inc speed#,speed_chg#
if controlkey()=1 then dec speed#,speed_chg#
if speed# > speed_max# then speed# = speed_max#
if speed# < speed_min# then speed# = speed_min#
move object 10,speed#
return
Navigation:
`LEFT/RIGHT
if leftkey()=1 then plyr_turn# = curvevalue(-2, plyr_turn#, 10)
if rightkey()=1 then plyr_turn# = curvevalue(2, plyr_turn#, 10)
if mx# = 0 then plyr_turn# = curvevalue(0, plyr_turn#, 10)
yrotate object 10,wrapvalue(object angle y(10)+plyr_turn#)
`UP/DOWN
if upkey()=1 then plyr_tilt# = curvevalue(1, plyr_tilt#, 20)
if downkey()=1 then plyr_tilt# = curvevalue(-1, plyr_tilt#, 20)
if my# = 0 then plyr_tilt# = curvevalue(0, plyr_tilt#, 10)
xrotate object 10,wrapvalue(object angle x(10)+plyr_tilt#)
`SMOOTH BANKING default 50
if leftkey()=1 then plyr_bank# = curvevalue(50, plyr_bank#, 25)
if rightkey()=1 then plyr_bank# = curvevalue(-50, plyr_bank#, 25)
if mx# = 0 then plyr_bank# = curvevalue(0, plyr_bank#, 25)
yrotate object OURID,plyr_bank#
I figure I can use the same code If i can just figure out how to implement it into the intercept sub. Basically, when the I key is held, it will act as an autopilot while my ship heads towards the target. After i figure this out, i'll fix it to where i wont have to hold down I, that it will follow until it reaches it, then match it's course and speed until i change my target.
Any suggestions anyone? Thanks in advance.