Created
July 9, 2018 22:25
-
-
Save Drenerdo/4a6babd0922c7bcf381e2cf663628d00 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class CharacterArms : MonoBehaviour | |
{ | |
protected int armIndex = 0; | |
public Rigidbody[] arm; | |
public Rigidbody chestBody; | |
protected float armCounter = 0; | |
protected int altarmIndex = 0; | |
public float armRate = 0.7f; | |
public float armRateIncreseByVelocity = 1f; | |
public float liftForce = 4; | |
public float moveForwardForce = 30; | |
public float holdDownForce = 100; | |
public bool attacking = false; | |
public void StopAttacking() | |
{ | |
attacking = false; | |
armCounter = armRate * 0.99f; | |
} | |
public void StartAttacking() | |
{ | |
attacking = true; | |
} | |
void Start() | |
{ | |
StartCoroutine("MoveArm"); | |
} | |
void FixedUpdate() | |
{ | |
Vector3 horizontalVelocity = chestBody.transform.forward; | |
horizontalVelocity.y = 0; | |
float speed = chestBody.velocity.magnitude; | |
horizontalVelocity.Normalize(); | |
if (armCounter >= armRate) | |
{ | |
AttackMode(); | |
} | |
} | |
IEnumerator MoveArm() | |
{ | |
arm[armIndex].AddForce(Vector3.up * liftForce * 15f); | |
yield return new WaitForSeconds(3f); | |
arm[armIndex].AddForce(Vector3.down * liftForce * 0); | |
yield return new WaitForSeconds(3f); | |
arm[armIndex].AddForce(Vector3.up * liftForce * 25f); | |
yield return new WaitForSeconds(3f); | |
arm[armIndex].AddForce(Vector3.down * liftForce * 0); | |
} | |
public void AttackMode() | |
{ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment