2022-03-21 15:09:21 +00:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
public class ArmSwingLocomotion : MonoBehaviour
|
|
|
|
{
|
|
|
|
public GameObject LeftHand;
|
|
|
|
public GameObject RightHand;
|
|
|
|
public GameObject CenterEyeCamera;
|
|
|
|
public GameObject ForwardDirection;
|
2022-04-04 14:15:27 +00:00
|
|
|
public GameObject Player;
|
2022-03-21 15:09:21 +00:00
|
|
|
|
|
|
|
private Vector3 PositionPreviousFrameLeftHand;
|
|
|
|
private Vector3 PositionPreviousFrameRightHand;
|
|
|
|
private Vector3 PlayerPositionPreviousFrame;
|
|
|
|
private Vector3 PlayerPositionCurrentFrame;
|
|
|
|
private Vector3 PositionCurrentFrameLeftHand;
|
|
|
|
private Vector3 PositionCurrentFrameRightHand;
|
|
|
|
|
|
|
|
public float Speed;
|
|
|
|
private float HandSpeed;
|
|
|
|
|
|
|
|
// Start is called before the first frame update
|
|
|
|
void Start()
|
|
|
|
{
|
2022-04-04 14:15:27 +00:00
|
|
|
PlayerPositionPreviousFrame = Player.transform.position;
|
2022-03-21 15:09:21 +00:00
|
|
|
PositionPreviousFrameLeftHand = LeftHand.transform.position;
|
|
|
|
PlayerPositionPreviousFrame = RightHand.transform.position;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update is called once per frame
|
|
|
|
void Update()
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-04-11 13:34:14 +00:00
|
|
|
/*float Yrot = CenterEyeCamera.transform.eulerAngles.y;
|
|
|
|
ForwardDirection.transform.eulerAngles = new Vector3(0, Yrot, 0);*/
|
2022-03-21 15:09:21 +00:00
|
|
|
|
|
|
|
PositionCurrentFrameLeftHand = LeftHand.transform.position;
|
|
|
|
PositionCurrentFrameRightHand = RightHand.transform.position;
|
|
|
|
|
2022-04-04 14:15:27 +00:00
|
|
|
PlayerPositionCurrentFrame = Player.transform.position;
|
2022-03-21 15:09:21 +00:00
|
|
|
|
|
|
|
//Debug.Log("Previous" + PositionPreviousFrameLeftHand);
|
|
|
|
//Debug.Log("Current" + PositionCurrentFrameLeftHand);
|
|
|
|
|
|
|
|
var playerDistanceMoved = Vector3.Distance(PlayerPositionCurrentFrame, PlayerPositionPreviousFrame);
|
|
|
|
var leftHandDistanceMoved = Vector3.Distance(PositionCurrentFrameLeftHand, PositionPreviousFrameLeftHand);
|
|
|
|
var rightHandDistanceMoved = Vector3.Distance(PositionCurrentFrameRightHand, PositionPreviousFrameRightHand);
|
|
|
|
|
|
|
|
HandSpeed = ((leftHandDistanceMoved - playerDistanceMoved) + (rightHandDistanceMoved - playerDistanceMoved));
|
|
|
|
|
|
|
|
if (Time.timeSinceLevelLoad > 1f)
|
|
|
|
{
|
2022-04-04 14:15:27 +00:00
|
|
|
Player.transform.position += ForwardDirection.transform.forward * HandSpeed * Speed * Time.deltaTime;
|
2022-03-21 15:09:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
PositionPreviousFrameLeftHand = PositionCurrentFrameLeftHand;
|
|
|
|
PositionPreviousFrameRightHand = PositionCurrentFrameRightHand;
|
|
|
|
|
|
|
|
PlayerPositionPreviousFrame = PlayerPositionCurrentFrame;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|