// Update is called once per frame void Update() { //if velocity is greater than zero, and is not gliding, and if movement buttons are pressed, rotate the character model to where the player is moving Vector3 groundVelocity = new Vector3(_parentRB.velocity.x, 0, _parentRB.velocity.z); Vector3 lookDir = new Vector3(charControlScript.GetComponent <Rigidbody>().velocity.x, 0, charControlScript.GetComponent <Rigidbody>().velocity.y); if (groundVelocity != Vector3.zero && !charControlScript.isGliding && (Mathf.Abs(Input.GetAxis("Horizontal")) >= 0.1f || Mathf.Abs(Input.GetAxis("Vertical")) >= 0.1f)) { transform.rotation = Quaternion.Lerp(transform.rotation, Quaternion.LookRotation(groundVelocity), 0.2f); } //rotate this child object to parent forward if (!once && charControlScript.isGliding) { transform.rotation = Quaternion.Euler(0, charControlScript.transform.eulerAngles.y, 0); once = true; } if (!charControlScript.isGliding && once) { once = false; } }
public void AddLevel() { if (currentLevel < maxLevel) { if (currentCP > 0 && requiredCP > 0 && !resetting) { charControlScript.GetComponent <MilestoneRankManager>().TotalCP--; currentNeededCP--; investedCP++; totalInvestedCP++; } } else { currentNeededCP = 0; } }
// Use this for initialization void Start() { maxHealth = 300; currentHealth = 300; enemyName = enemyNameList[Random.Range(0, enemyNameList.Length)]; thisTransform = GetComponent <Transform>(); thisRigidbody = GetComponent <Rigidbody>(); player = GameObject.Find("Player").GetComponent <CharControl>(); playerTransform = player.GetComponent <Transform> (); GM = GameObject.Find("GameManager").GetComponent <GameManager>(); switch (Random.Range(1, 5)) { case 1: uiColor = Color.cyan; break; case 2: uiColor = Color.yellow; break; case 3: uiColor = Color.green; break; case 4: uiColor = Color.magenta; break; default: uiColor = Color.magenta; break; } defaultMovement = Random.Range(9, 12); turnSpeed = Random.Range(7, 11); }
private void GUIAnimationButtons() { if (m_currentCharControl == null) { return; } AnimationList aniList = m_currentCharControl.GetComponent <AnimationList>(); if (aniList == null) { return; } foreach (string ani in aniList.m_animationList) { if (GUILayout.Button(ani, size) == true) { Spwan[] spwans = GameObject.FindObjectsOfType <Spwan>(); if (spwans.Length == 0) { AnimationList[] als = GameObject.FindObjectsOfType <AnimationList>(); foreach (AnimationList al in als) { al.PlayAnimation(ani); } } else { foreach (Spwan spwan in spwans) { spwan.AnimationTest(ani); } } } } }