• Mouse Aim steering
    6 replies, posted
I'm trying to write an E2 flying holo vehicle that's controlled by mouse aim in third person view (like vehicles in Halo), but after looking around on YouTube and searching the forums I haven't been able to find anything that sheds some insight on how to write an E2 camera script that pivots around an entity (the effect I'm after can be replicated by going into third person while sitting in a seat). The control and other fancy stuff I can do myself, but I'd just like some help with the camera.
You might be able to use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Player/Spectate]Player:Spectate[/url] with OBS_MODE_CHASE or OBS_MODE_ROAMING, or try [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/CalcView]GM:CalcView[/url] Sorry if E2 doesn't have similar functions to this - I'm not familiar with it, but this would work for regular addons
Assuming propcore is enabled you can just move a camera behind the vehicle to simulate this effect. ply:eye() Returns a normalized vector of the players view. Multiply this by the amount you want to zoom out. Subtract the multiplied direction from the players position to get the camera position. The angle should just be the angle between the camera's position and the vehicle. [CODE]Camera:setPos(Vehicle:driver():pos() - Vehicle:eye() * 1000) Camera:setAng((Vehicle:pos() - Camera:pos()):toAngle())[/CODE]
[QUOTE=gmatt1923;52381441]Assuming propcore is enabled you can just move a camera behind the vehicle to simulate this effect. ply:eye() Returns a normalized vector of the players view. Multiply this by the amount you want to zoom out. Subtract the multiplied direction from the players position to get the camera position. The angle should just be the angle between the camera's position and the vehicle. [I]*snip*[/I] [/QUOTE] I modified your code so that it worked for an entity instead of the player. It works very well now, except for the fact that it's unfortunately jittery as hell. I think I might not go ahead with using mouseaim and will settle for WASD control instead :buckteeth: [editline]21st June 2017[/editline] Here's what I did: [CODE] Pos = Ship:pos() # CAMERA SETTINGS CamAng = Ship:owner():eyeAngles() CamPosX = Pos:x()-CamRad*cos(CamAng:yaw())*cos(CamAng:pitch()) CamPosY = Pos:y()-CamRad*sin(CamAng:yaw())*cos(CamAng:pitch()) CamPosZ = Pos:z()+CamRad*sin(CamAng:pitch()) CamPos = vec(CamPosX,CamPosY,CamPosZ)[/CODE] "Ship" is a holo entity representing the core of the ship, "CamAng" and "CamPos" are outputs wired to the angle and position inputs of a cam controller, and "CamRad" is the desired distance of the camera from the core Now I'm trying to figure out how to make it tilt when turning, but for some reason I can't get the velocity of the core holo entity :(
Does anyone know how I can fix a problem I'm getting whenever I cross the 0 degree heading line? Whenever I cross it with my view the ship won't cut across the line to reach the heading, and instead goes the long way round.
[URL="https://github.com/wiremod/wire-extras"]wire-extras[/URL] has a camera extension for E2 you might wanna look into
If you don't mind spawning additional entities, wiremod has a camera controller you can use.
Sorry, you need to Log In to post a reply to this thread.