MMO Style thirdperson cam? (+ walking in dir. of WASD keys)

Hello, I am trying to create a mmo-style thirdperson and movement system where the camera can rotate around the player. Not only this, but I want it so that whenever you press the WASD keys the character turns and moves in that direction relative to your screen- or the angle to which the camera itself is pointing- rather than relative to the playermodel.

For the thirdperson rotation system, I’m using a modified calcview- this seems to be working decent enough so far. (I won’t show it here unless requested).

It is the movement system I need help figuring out. Since this takes place on the serverside, I’m not exactly sure how I’d get the angles of calcview required for such a move. I’m trying to use the ‘Move’ system and cmd:GetViewAngles(), but the character still seems to be moving relative to its own model and not the actual calcview models. Here’s what I have so far:

(Note: I’m testing this in singleplayer but it says something about this being “predicted” and not functional in singleplayer (on the client). Will this affect my testing of it?)

-- Ok so this is a shared hook but gmod says it's 'predicted' so in singleplayer won't be called on the client
-- Let's just make it a serverside file for now until I can figure out what I'm doing

hook.Add( "SetupMove", "MyThirdPerson", function( ply, mv, cmd )

	if mv:KeyDown(IN_FORWARD) then
		local viewangles = cmd:GetViewAngles()
		mv:SetMoveAngles( viewangles:Forward():Angle() )
	end
	if mv:KeyDown(IN_BACK) then
		local viewangles = cmd:GetViewAngles()
		mv:SetMoveAngles( viewangles:Forward():Angle() )
	end
	if mv:KeyDown(IN_RIGHT) then
		local viewangles = cmd:GetViewAngles()
		mv:SetMoveAngles( viewangles:Right():Angle() )
	end
	if mv:KeyDown(IN_LEFT) then
		local viewangles = cmd:GetViewAngles()
		mv:SetMoveAngles( viewangles:Right():Angle() )
	end
	
end )

Bump

I would start to approach either of two ways, one you try to do the camera angles serverside, two you get the client to tell the server what direction you want to move in. The best approach is probably trying to sort the camera angles on the server instead.

All you would need to do on the server is adjust an angle around the player I guess. Not really sure on what would be best but maybe that helps a little.

1 Like