E2 Question: ApplyAngForce() Steering

So, im working on a hover car and i want to make it steer with the mouse. aka look to the left, it turns left until you look straight. look to the right, it turns right until you look straight.

So far it attaches to a plate with a pod controler and 2 seats mounted to it. makes it hover and fly in the air.

Heres my code:



@name Hover Controler
@inputs Pod:wirelink
@persist FlyMode
runOnTick(1)

if(first()){
    entity():isWeldedTo():soundPlay(1,0,"ambient/electrical/amb_abstract_energy_lp_01.wav")   
}

R=rangerOffset(10000,entity():isWeldedTo():pos(),vec(0,0,-1))
rangerFilter(entity():isWeldedTo())
rangerFlags("W")

if(R:distance()<250&Pod["Space" ,number]==0){
    entity():isWeldedTo():applyForce(((R:position()+vec(0,0,50)-entity():pos())*entity():isWeldedTo():mass())+vec(0,0,((0-entity():vel():z())*100)))
}

if(FlyMode==1&R:distance()<250){   
    entity():isWeldedTo():soundPlay(3,0,"buttons/combine_button1.wav")
    FlyMode = 0
}
if(FlyMode!=1&R:distance()>250){    
    entity():isWeldedTo():soundPlay(2,0,"buttons/combine_button5.wav")
    FlyMode = 1
}

entity():isWeldedTo():applyAngForce(ang((0-entity():isWeldedTo():angles():pitch())*10000,0,(0-entity():isWeldedTo():angles():roll())*100000)+((0-entity():isWeldedTo():angVel())*10000))


if(R:distance()<65&Pod["Space" ,number]==0){entity():isWeldedTo():propGravity(1)}else{entity():isWeldedTo():propGravity(0)}

entity():isWeldedTo():applyAngForce(ang((0-entity():isWeldedTo():angles():pitch())*10000,0,(0-entity():isWeldedTo():angles():roll())*10000))


if(Pod["A" ,number]){entity():isWeldedTo():applyForce((entity():isWeldedTo():forward()*5000)*((FlyMode*2)+1))}
if(Pod["D" ,number]){entity():isWeldedTo():applyForce((0-(entity():isWeldedTo():forward()*5000))*((FlyMode*2)+1))}
if(Pod["W" ,number]){entity():isWeldedTo():applyForce((entity():isWeldedTo():right()*5000)*((FlyMode*2)+1))}
if(Pod["S" ,number]){entity():isWeldedTo():applyForce((0-(entity():isWeldedTo():right()*5000))*((FlyMode*2)+1))}

if(Pod["Space" ,number]){entity():isWeldedTo():applyForce(vec(0,0,entity():mass()*9999))}

if(Pod["Shift" ,number]){entity():isWeldedTo():applyForce(0-(vec(0,0,entity():mass()*9999)))}

if(Pod["Active" ,number]){entity():propFreeze(0)}else{entity():propFreeze(1)}

soundPitch(1,((vec():distance(entity():vel())+25)/10)/((FlyMode*2)+1),0)



I would like to include some code that will make it steer.

A cheap way I used to do mouse control of things was use a tank aiming chip, and limit the elevation.

Also runOnTick is bad, use an interval of 50 or something

Basicaly what you want is this. A mouse aim like that is pretty shit tho



E = entity():isWeldedTo()
E:applyAngForce( ang( 0, clamp( Pod["Entity" ,entity]:driver():eyeAngles():yaw(), -10, 10 ), 0 ) * E:mass() )

It just starts wiggleing around like crazy.



@inputs Vehicle:entity
@outputs 
@persist Entity:entity Inertia:angle
@trigger none
@model models/hunter/plates/plate1x1.mdl

if (first()) {
    Entity = entity()
    Inertia = shiftL(ang(Entity:inertia()))
}

interval(60)

DriverEye = Vehicle:toLocalAxis(Vehicle:driver():eye()):toAngle()

Entity:propGravity(0)
Entity:applyAngForce((Entity:toLocal(ang(0, DriverEye:yaw(), 0))*200 - Entity:angVel()*20) * Inertia)


Try something like that. You might also need to use a cam controller if your vehicle is attached to the rotating prop.