Quantcast
Channel: Questions in topic: "enemy"
Viewing all articles
Browse latest Browse all 1488

Fist Punch Collision

$
0
0
Hi everyone, i'm making a first person boxing game that is a player against an enemy. So i've got a first person controller, then i add two arms with front punch animation (left arm and right arm) and then i attached to the fists an sphere collider to get when it hits the enemy collider. The problem is when i play the animation on mousedown the sphere collider doesn't move and the fists overstep the enemy collider and don't activate the collider. What can i do to detect the hit? This is part of my code for e.g: using UnityEngine; using System.Collections; public class RightPunchScript : MonoBehaviour { public GameObject Enemy; private Animation anim; void Start(){ anim = GetComponent (); } public void OnCollisionEnter (Collider other){ if (other.gameObject.tag == "Enemy"){ Debug.Log ("I hit the Enemy!"); Enemy.GetComponent ().EnemyDamage (); } } void Update(){ if (Input.GetMouseButtonDown(1)){ anim.Play("RightPunch"); } } }

Viewing all articles
Browse latest Browse all 1488

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>