by Caligari87 » Fri Mar 23, 2018 2:54 pm
I'm designing a new movement system for the mod I'm working on. In short, the player actor is just the head; the legs and torso are separate actors. Locomotion is acheived by imparting velocity to the legs, and the torso+head follows on a spring. I want idea to implement leaning (since the player's full-body hitbox is no longer relevant). To do this, I wanted to use the Strafe key as a toggle, to impart velocity to the player's head and torso instead of the legs.
Code: Select all
void UpdateMove() {
let player = self.player;
UserCmd cmd = player.cmd;
if (player.onground) {
legs.vel.xy *= 0.75; //Decelerate
if(cmd.buttons & BT_STRAFE) {
vel.xy += rotateVector((moveVec.x, 0), angle - 90) * 5 / player.crouchfactor; //Move head
torso.vel.xy += rotateVector((moveVec.x, 0), angle - 90) * 5 / player.crouchfactor; //Move torso
legs.vel.xy += rotateVector((0, moveVec.y), angle - 90); //allow moving forward/back
}
else {
legs.vel.xy += rotateVector(moveVec, angle - 90); //Move legs
}
}
}
This works perfectly (video demo), except for a small detail: The player's mouse yaw gets pushed into sidemove, meaning the player can no longer freelook and the leaning gets overriden by any mouse yaw behavior. I can take a video demo of this later if desired.
My suggestion is that the conversion/override should be exported to PlayerPawn, so this behavior can be overridden.

I'm designing a new movement system for the mod I'm working on. In short, the player actor is just the head; the legs and torso are separate actors. Locomotion is acheived by imparting velocity to the legs, and the torso+head follows on a spring. I want idea to implement leaning (since the player's full-body hitbox is no longer relevant). To do this, I wanted to use the Strafe key as a toggle, to impart velocity to the player's head and torso instead of the legs.
[code]void UpdateMove() {
let player = self.player;
UserCmd cmd = player.cmd;
if (player.onground) {
legs.vel.xy *= 0.75; //Decelerate
if(cmd.buttons & BT_STRAFE) {
vel.xy += rotateVector((moveVec.x, 0), angle - 90) * 5 / player.crouchfactor; //Move head
torso.vel.xy += rotateVector((moveVec.x, 0), angle - 90) * 5 / player.crouchfactor; //Move torso
legs.vel.xy += rotateVector((0, moveVec.y), angle - 90); //allow moving forward/back
}
else {
legs.vel.xy += rotateVector(moveVec, angle - 90); //Move legs
}
}
}[/code]
[url=https://streamable.com/37jgk]This works perfectly (video demo)[/url], except for a small detail: The player's mouse yaw gets pushed into sidemove, meaning the player can no longer freelook and the leaning gets overriden by any mouse yaw behavior. I can take a video demo of this later if desired.
My suggestion is that the conversion/override should be exported to PlayerPawn, so this behavior can be overridden.
8-)