how does PitchYawRoll work with calcview?

hello again =)

once again i need help from you guys, and once again its a newbie question :slight_smile: //or better :((

i want to use calcview (instead of “setang”) to change the pitch, yaw and roll of my view.
the problem i got, is that my incoming datastream somehow only affects the yaw, and its affected by all values, so if the pitch value changes, the yaw reacts… and so forth

here s my code:



require("oosocks")

local connection = OOSock(IPPROTO_UDP);

connection:SetCallback(function(socket, callType, callId, err, data, peer, peerPort)
    if(callType == SCKCALL_BIND && err == SCKERR_OK) then
        print("Bound.");
        connection:ReceiveDatagram();
    end
     
    if(callType == SCKCALL_REC_DATAGRAM && err == SCKERR_OK) then
		
		local stringeddata = tostring(data) 
		local ControlNodes = string.Explode(" ", stringeddata) 
		
		p = ControlNodes[1]
		r = ControlNodes[2]
		y = ControlNodes[3] 		
		
		viewValues = Angle(p, y, r) --converting the the string values to Angle
		
		hook.Add("CalcView", "Pitch Yaw Roll", calcViewAngle, viewValues)
		
		connection:ReceiveDatagram();
    end
end);


 function calcViewAngle(ply, pos, angles, fov)
	local view = {}
    view.origin = origin
	view.angles = viewValues -- here the pitch yaw roll values should be changed
	view.fov = fov	
    return view
end

connection:Bind("localhost", 5003);


im sure its just a little change thats needed, so sorry to bother you
and thanks for reading it!

numu

Make sure the values to numbers, they’re still strings. Angle() accepts a string as the first argument, but it would look like Angle(“1, 2, 3”); since that only uses the first argument (and your first argument is a string), the rest is ignored. So it’d make sense it affects one value.

hey!
thanks for the reply!
this sounds logic to me (though i didnt know that i need number for Angle(), but its obvious)

i converted them now, but like this, nothing is moving anymore, when i print the values i get 1 at each of them… and no change is happening :confused:

here the code



require("oosocks")

local connection = OOSock(IPPROTO_UDP);

connection:SetCallback(function(socket, callType, callId, err, data, peer, peerPort)
    if(callType == SCKCALL_BIND && err == SCKERR_OK) then
        print("Bound.");
        connection:ReceiveDatagram();
    end
     
    if(callType == SCKCALL_REC_DATAGRAM && err == SCKERR_OK) then
		
		local stringeddata = tostring(data) 
		local ControlNodes = string.Explode(" ", stringeddata) 
		
		p_n = ControlNodes[1]
		r_n = ControlNodes[2]
		y_n = ControlNodes[3]	
		
		hook.Add("CalcView", "PitchYawRoll", calcViewAngle, p_n, y_n, r_n)
		
		connection:ReceiveDatagram();
    end
end);


 function calcViewAngle(ply, pos, angles, fov)
	p = tonumber(p_n)
	y = tonumber(y_n)
	r = tonumber(r_n)
	
	local angles = Angle(p, y, r)
	local view = {}
    view.origin = origin
	view.angles = angles
	view.fov = fov	
	print(view.angles.p)
    return view
end

connection:Bind("localhost", 5003);




thanks !
numu

It looks like you’re looking for hook.Call rather than hook.Add, but I suggest you keep a local variable at the beginning of the file and define it in the callback.