@name ApplyForceTesting2
@inputs Pod:wirelink 
@persist Pos:vector
interval(100)

if (changed(Pod) | first()) {
    # Declarations
    Pos=Pod:entity():pos()
    
    
    ##########################
    # Mantle Angle Functions #
    ##########################
    
    # Convert two vectors to an angle with ang
    function angle ang(V1:vector,V2:vector) {
        return (V2-V1):toAngle()
    }
    
    function number ang(V1:vector2,V2:vector2) {
        return (V2-V1):toAngle()
    }
    
    # Determine path of least resistance to reach another angle
    function number swivel(A:number,B:number) {
        local C1=(B+(360-A))%360
        local C2=C1-360
        return abs(C1)<abs(C2) ? C1 : C2
    }
    
    function angle swivel(A:angle,B:angle) {
        return ang(
            swivel(A:pitch(),B:pitch()),
            swivel(A:yaw(),B:yaw()),
            swivel(A:roll(),B:roll())
        )
    }
    
    ##########################
    # Mantle Force Functions #
    ##########################
    
    function number entity:rotate(Ang:angle,Speed:normal) {
        This:applyAngForce((swivel(This:angles(),Ang)-This:angVel())*This:mass()*Speed)
        return 1
    }
    
    function number entity:rotate(Ang:angle) {
        This:rotate(Ang,1)
        return 1
    }
    

    
    function number entity:move(Vec:vector,Speed:normal) {
        This:applyForce(((Vec-This:pos())-This:vel())*This:mass()*Speed)
        return 1
    }
    
    function number entity:move(Vec:vector) {
        This:move(Vec,1)
        return 1
    }
    
    function number entity:moveNoReset(Vec:vector,Speed:normal,Slowdown:normal) {
        This:applyForce(((Vec-This:pos()-This:vel()*Slowdown))*This:mass()*Speed)
        return 1
    }
	

    
    
}

local Seat = Pod["Entity",entity]
local Driver = Seat:driver()
local W = Driver:keyForward()
local A = Driver:keyLeft()
local S = Driver:keyBack()
local D = Driver:keyRight()
local R = Driver:keyReload()
local Mouse1 = Driver:keyAttack1()
local Mouse2 = Driver:keyAttack2()
local Shift = Driver:keySprint()
local Active = Driver:isPlayer()
local PodEnt=Pod:entity()

# Movement matrix
Pos+=
    (
        (W ? PodEnt:forward() : vec()) +
        (S ? PodEnt:forward()*-1 : vec()) +
        (A ? PodEnt:right() : vec()) +
        (D ? PodEnt:right()*-1 : vec())
    ) * 5

PodEnt:move(Pos)
PodEnt:rotate(ang())
