Character slows down when rotating the camera

Im trying to work on a top down perspective game and with some input features. I tried to implement a feature where if i press the MiddleMouseButton and the player is not moving, the cmaera rotates around the player and updates the new control rotation, if im moving while rotating the camera then the player should also rotate towards the new Rotation, he does that but also moves really slow and jitters while moving

1 Like


here a showcase

Can you showcase the script, I feel you’re feeding the character a vector directed into the floor.


camera code


middle mouse button code

horizontal
my code to rotate the character while moving


Normal Movement Code

The Control Rotation is matching that of the springarm’s, and then we’re moving along it - it’s pointing towards the floor and will change with camera angles, too. The character cannot take advantage of the full vector, this will be inconsistent. May be more / less noticeable in some cases.

For a quick fix, try this for moving forward:

The right vector can stay as is. Ideally, do not set the Control Rotation towards the floor - this would be useful for a diving aeroplane, not so much for a char walking on mostly flat surfaces, where the movement comp takes care of the traversal anyway.

4 Likes

Tried it and it seems to work. My Player Char runs at a consistent speed now, thanks

2 Likes

Maybe you know a solution for this too: i just noticed that the aim of my weapon is off from where my mouse aims, it aims to the right of it.
Bild_2023-05-24_131052540
aimingerror

probably because the gun is held with a slight offset

It’s probably due to the tracing method used. As in:

  • the character is 180uus, we trace from the gun socket which is somewhere around 110 uus above ground
  • the end of the trace hits the ground at 0
  • cursor mouse to world does not account for all of it

It’s wild guessing without seeing the script.

Also, not sure how you need it to work against ramps / verticality. If we point at the top of the pillar, should we fire at its side or at its top? The features and behaviours needed would partially dictate how to handle it all.



this is currently of i aim at the mouse location

ill try to make a short video of how i want it to work

My bet is that the character is Looking At one way, as in the script, but the weapon we’re holding is at an angle and we;re tracing along its forward:

Hard to tell. Arrow angles above exaggerated for dramatic effect.

1 Like

1 Like

took this out of the Game “Foxhole”


well for me it looks like my character does look straight at my mouse location but the gun is aimed at an angle so it faces to the right

Try this:

The second trace is optional.

well for me it looks like my character does look straight at my mouse location but the gun is aimed at an angle so it faces to the right

Aye, that’s a part of it. You’re rotating the entire actor:

If the gun is offset, tracing along the gun’s fwd will also be offset.

yeah also i tried the code above and it does some weird trace stuff

Better vid, to clarify what the script is supposed to be doing.


Not sure what you’re expecting atm, the character points one way and the gun the other way. It’s a design issue. You need to make a choice, either you rotate the gun and the character follows that rotation. Or you rotate the character and the gun stays askew until you remodel the hands / sockets / attachment angles.

In the Foxhole vid, the upper torso is twisting, the legs are not. The rotation of the upper body matches that of the gun and things line up.

rotating the gun would probably be the best option

line plane intersection only works in X,Y dimensions right?

It works for everything, every angle and surface imaginable. Feed it desired location and normal. And it does not rely on geometry, you do not need to use it. You can trace as you were and add +90z to the result.

But it’s a handy tool, sometimes you may have a body of water / foliage you do not want to take into account. And handy if you want to have this floaty feeling when cursor appears above ground, because we’re actually stopping the trace above the surface and intersect our virtual plane instead.