Check out Half-Life Re-imagined competition results!
Check out Skewing textures in Hammer, our newest tutorial!
Say hello to timadam, our newest member!

logo

Site Stuff

Reference

Maps

Community

ShoutBOX

Poll

Feeling Blue

What's your favourite shade of blue?

Azure

20

Cobalt

36

Turquoise

11

Cyan

17

Royal

11

Teal

3

Onliners

9 mins

Instant Mix

10 mins

UrbaNebula

27 mins

Dimbeak

30 mins

Jessie

1 hours

Strider

1 hours

NineTnine

2 hours

JeffMOD

Affiliates

A gaming and technology blog by TWHL admins Penguinboy and Ant. A music blog by TWHL users Ant and Hugh.

A bug with player viewangles based on se

[1]

Forums > HL Engine Discussion

29 Jan 18, 08:34
By crystallize
avatar
Member
Hello TWHL.
I hope you'll help me to sort out this trouble I'm having.
The thing is, I'm a noob coder and I'm trying to make Sonic Adventure/Soul Reaver-like camera and controls, I've stuck at the very beginning though.

First what I did was going to server camera code and skipping that chunk of code that softens up camera movement: now difference between hmtarget and camera origin is written into pev->angles right away, we've got an instant rotation.

Then on client side, IN_JoyMove to be precise, I had to get camera angles.
(I tried making a custom message from server, then I tried GetEntityByIndex( viewEntityIndex ), the effect was the same)

To achieve this kind of controls I have to take an angle given by input device and transform it from the coordinates based on camera axis to global coordinates, it can be done either by rotating a 3d vector or simply adding two yaw values, I tried both.

The thing is I kinda got what I needed, but making player to go pure 90 degree to the side (and remember that camera follows him) doesn't really make him run a perfect circle around the camera as one would expect, I'm getting a gradual spiral instead.

Yaw value calculated for the player is wrong by from 60 degrees (right under the camera) to about zero when he's a few hundred units away. I wonder is it engine architecture issue or I've ran into some kind of basic geometrical law.

https://www.youtube.com/watch?v=_hEam9Uk_fs
30 Jan 18, 16:38
By Solokiller
avatar
Member
How are you setting the angles on the server side? You need to use pev->fixangle to force the engine to set a particular angle, and both pev->angles and pev->v_angle need to be set to be correct.
31 Jan 18, 15:43
By crystallize
avatar
Member
I just did
pev->angles = UTIL_VecToAngles( m_hTarget->pev->origin - pev->origin );
and comented the rest of FollowTarget.
31 Jan 18, 17:16
By Solokiller
avatar
Member
Then you should try setting fixangle to 1 right after that, it should tell the engine to set exactly that angle.
01 Feb 18, 02:21
By crystallize
avatar
Member
Ok I'll try fixangle (and ef_nointerp). But doesn't that line I broght up above is doing exactly that, calculating vector between camera and its target, converting it to angles and immediately applying them to camera without any smooth transition?
12 Apr 18, 17:45
By crystallize
avatar
Member
Well it doesn't work.
pev->avelocity.x = dx * 40 * gpGlobals->frametime;
pev->avelocity.y = dy * 40 * gpGlobals->frametime;

pev->fixangle = TRUE;
pev->effects = EF_NOINTERP;

if (!(FBitSet (pev->spawnflags, SF_CAMERA_PLAYER_TAKECONTROL)))

Now to client side. If we do this:

gEngfuncs.SetViewAngles( (float *)viewentity->angles );
gEngfuncs.Con_Printf( "yawdiff cam,pl = %f\n", viewentity->angles[1]-player->curstate.angl
es[1]);

We can see that these angles just aren't the same despite the fact that we just copied them over. The difference can be as big as half a degree for player about 300 units from camera.
22 Apr 18, 16:06
By crystallize
avatar
Member
Tried the same with client-side camera, still no luck. The issue seems to be how player's movement direction is defined by his viewangles (obviously) but they are only updated after being sent to server which adds 1 frame-long lag. Every frame client is dealing with player's incorrect viewangles from previous frame which probably creates this bug.
I thought, may be I'll delay as many values as possible for 1 frame and apply them there. I assumed how 1 frame equals going through client's main loop anew and going through V_CalcThirdpersonRefDef from the beginning so I calculated some values at the end of the function and applied them at the beginning, but the issue remained.
[1]

Forums > HL Engine Discussion

Login to Reply

You must be logged in to reply.