Saturday, June 30, 2012

Gmod Third Person View Using Wire And E2 - v2

I made a new version of the third person view, which let you move the camera up and down on the pitch rotation.



And here's the E2 "third_person_v2" code:
@name third Person v2
@inputs
@outputs Angle:angle Position:vector
@persist
@trigger

runOnTick(1)

R = 120

Angle = owner():eyeAngles()
Pitch = Angle:pitch()
Yaw = Angle:yaw()

X = cos(Yaw) * R * (-1)
Y = sin(Yaw) * R * (-1)
Z = sin(Pitch) * R + 90

Zx = R - (cos(Pitch) * R)
Xz = cos(Yaw) * Zx
Yz = sin(Yaw) * Zx

if(Z < 0){Z = 0}
Position = owner():pos() + vec(X+Xz,Y+Yz,Z)