mirror of
https://github.com/DerTyp7/defrain-shooter-unity.git
synced 2025-10-29 20:52:10 +01:00
Procedual Animation Hand Fix
See "Procedual Animation Hand Fix" issue
This commit is contained in:
@@ -1,34 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class AimDownSights : MonoBehaviour
|
||||
{
|
||||
[SerializeField] float aimSpeed = 0.01f;
|
||||
[SerializeField][Range(0,1)] public float aimVal = 0;
|
||||
[SerializeField] private GameObject gun;
|
||||
[SerializeField] GameObject AimPoint;
|
||||
[SerializeField] GameObject HoldPoint;
|
||||
public bool isAiming = false;
|
||||
bool ADS()
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
||||
private void FixedUpdate()
|
||||
{
|
||||
if (Input.GetButton("Aim"))
|
||||
{
|
||||
isAiming = true;
|
||||
aimVal += aimSpeed;
|
||||
}
|
||||
else
|
||||
{
|
||||
isAiming = false;
|
||||
aimVal -= aimSpeed;
|
||||
}
|
||||
aimVal = Mathf.Clamp(aimVal,0,1);
|
||||
|
||||
gun.transform.position = Vector3.Lerp(HoldPoint.transform.position, AimPoint.transform.position,Mathf.Pow(aimVal,1.3f)) ;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 916f2d37f60a91149bbca3280a1b69ec
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,78 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Mirror;
|
||||
public class Headbob : NetworkBehaviour
|
||||
{
|
||||
[SerializeField] private PlayerController playerController;
|
||||
[SerializeField] private ShootAnimation gunAnimation;
|
||||
|
||||
|
||||
[SerializeField] private float posCheckDistance = 0.01f;
|
||||
[SerializeField] private float checkDist = 0.0f;
|
||||
private float currentDist = 0;
|
||||
|
||||
[Header("Step Settings")]
|
||||
[SerializeField] private float stepAmplitudeWalking;
|
||||
[SerializeField] private float stepAmplitudeSprinting;
|
||||
[SerializeField] [Range(0.01f, 10.0f)] private float stepFrequency;
|
||||
[SerializeField] private Transform Neck;
|
||||
|
||||
private Vector3 lastPos;
|
||||
private Vector3 startPos;
|
||||
private Vector3 newPos;
|
||||
private float oldDist = 0;
|
||||
private float lerpVal = 0;
|
||||
|
||||
|
||||
[Header("Gun Settings")]
|
||||
[SerializeField] GameObject gunRotation;
|
||||
[SerializeField] float rotationMultiplier = 0.1f;
|
||||
|
||||
|
||||
|
||||
private void Start()
|
||||
{
|
||||
lastPos = this.transform.position;
|
||||
//startPos = this.transform.position;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
|
||||
float amplitude;
|
||||
if (playerController.isGrounded)
|
||||
{
|
||||
lerpVal = 0;
|
||||
float dist = Vector3.Distance(lastPos, this.transform.position);
|
||||
if (playerController.isSprinting)
|
||||
amplitude = stepAmplitudeSprinting;
|
||||
else
|
||||
amplitude = stepAmplitudeWalking;
|
||||
|
||||
if (dist > posCheckDistance)
|
||||
{
|
||||
currentDist += dist;
|
||||
lastPos = this.transform.position;
|
||||
}
|
||||
else
|
||||
{
|
||||
checkDist = currentDist + dist;
|
||||
}
|
||||
gunAnimation.gunSideSwey(getSin(amplitude, stepFrequency/2, checkDist),playerController.inputDirection.magnitude);
|
||||
newPos = new Vector3(getSin(amplitude / 2, stepFrequency, checkDist), getSin(amplitude, stepFrequency, checkDist), 0);
|
||||
Neck.localPosition = newPos;
|
||||
}
|
||||
else
|
||||
{
|
||||
Neck.localPosition = Vector3.zero;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private float getSin(float multiplier, float devisor,float x)
|
||||
{
|
||||
return multiplier * Mathf.Sin((x/3.14f) * 10 * devisor);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4db7caf602ce379408a59c8722e06e46
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,28 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Mirror;
|
||||
|
||||
public class PlayerColor : NetworkBehaviour
|
||||
{
|
||||
[SyncVar(hook = "SetColor")]
|
||||
public Color color;
|
||||
public Renderer renderer;
|
||||
|
||||
void SetColor(Color oldColor, Color newColor)
|
||||
{
|
||||
if (color == null)
|
||||
{
|
||||
color = renderer.material.color;
|
||||
}
|
||||
|
||||
renderer.material.color = newColor;
|
||||
color = newColor;
|
||||
|
||||
}
|
||||
|
||||
public override void OnStartClient()
|
||||
{
|
||||
renderer.material.color = color;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 00dc60b61b501f2419e2abd7158be5f8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -161,7 +161,6 @@ public class PlayerController : NetworkBehaviour
|
||||
moveDirection = new Vector3(moveDirection.x, 0, moveDirection.z);
|
||||
currentDir = moveDirection;
|
||||
}
|
||||
Debug.Log(currentMaxSpeed);
|
||||
velocity = Vector3.SmoothDamp(velocity, currentDir * currentMaxSpeed + new Vector3(0, velocityY, 0),ref refVelocity,moveSmoothTime);
|
||||
localVelocity = transform.InverseTransformDirection(velocity);
|
||||
controller.Move(velocity * Time.deltaTime);
|
||||
|
||||
@@ -5,6 +5,14 @@ using Mirror;
|
||||
|
||||
public class ProcedualAnimationController : NetworkBehaviour
|
||||
{
|
||||
[Header("Hand Settings")]
|
||||
[SerializeField] private Transform rightHandREF;
|
||||
[SerializeField] private Transform leftHandREF;
|
||||
[SerializeField] private Transform gunRightHandREF;
|
||||
[SerializeField] private Transform gunLeftHandREF;
|
||||
[SerializeField] private Vector3 defaultRightHandPosition = Vector3.zero;
|
||||
[SerializeField] private Vector3 defaultLeftHandPosition = Vector3.zero;
|
||||
|
||||
|
||||
[Header("Step Settings")]
|
||||
[SerializeField] private float stepAmplitudeWalking;
|
||||
@@ -99,6 +107,28 @@ public class ProcedualAnimationController : NetworkBehaviour
|
||||
playerAnimator.SetFloat("x", playerController.localVelocity.x / playerController.currentMaxSpeed);
|
||||
playerAnimator.SetFloat("y", playerController.localVelocity.z / playerController.currentMaxSpeed);
|
||||
}
|
||||
|
||||
public void handPositioning()
|
||||
{
|
||||
if (gunRightHandREF != null)
|
||||
{
|
||||
rightHandREF.position = gunRightHandREF.position;
|
||||
rightHandREF.rotation = gunRightHandREF.rotation;
|
||||
}
|
||||
else
|
||||
{
|
||||
rightHandREF.position = defaultRightHandPosition;
|
||||
}
|
||||
if (gunLeftHandREF != null)
|
||||
{
|
||||
leftHandREF.position = gunLeftHandREF.position;
|
||||
leftHandREF.rotation = gunLeftHandREF.rotation;
|
||||
}
|
||||
else
|
||||
{
|
||||
leftHandREF.position = defaultLeftHandPosition;
|
||||
}
|
||||
}
|
||||
public void OnSwitchWeapon(GameObject currentWeapon)
|
||||
{
|
||||
if (isLocalPlayer) {
|
||||
@@ -141,7 +171,7 @@ public class ProcedualAnimationController : NetworkBehaviour
|
||||
if (isLocalPlayer)
|
||||
{
|
||||
walkAnimation();
|
||||
|
||||
handPositioning();
|
||||
CmdAim(Input.GetButton("Aim"));
|
||||
}
|
||||
/*-----Aiming-----*/
|
||||
|
||||
Reference in New Issue
Block a user