Skip to content

Instantly share code, notes, and snippets.

@Drenerdo
Created July 9, 2018 22:25
Show Gist options
  • Save Drenerdo/4a6babd0922c7bcf381e2cf663628d00 to your computer and use it in GitHub Desktop.
Save Drenerdo/4a6babd0922c7bcf381e2cf663628d00 to your computer and use it in GitHub Desktop.
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