void RaycastPlayer() { Vector3 forward = transform.TransformDirection(Vector3.forward) * RayDistance; Debug.DrawRay(transform.position, forward, Color.green); if (Physics.Raycast(transform.position, (forward), out hit)) { theDistance = hit.distance; //print(theDistance + " " + hit.collider.gameObject.name); //เปลียนหน้าดิน if (hit.collider.tag.Equals("Wood")) { TargetHit target = hit.transform.GetComponent <TargetHit>(); Destruction swapTarget = hit.transform.GetComponent <Destruction>(); if (swapTarget != null) { swapTarget.SwapObject(); target.TakeDamage(damage); } //Instantiate(destroyedVersion, transform.position, transform.rotation); } } }
void RaycastPlayer() { Vector3 forward = transform.TransformDirection(Vector3.forward) * RayDistance; Debug.DrawRay(transform.position, forward, Color.green); if (Physics.Raycast(transform.position, (forward), out hit)) { theDistance = hit.distance; //print(theDistance + " " + hit.collider.gameObject.name); //ทำลายสิ่งของ TargetHit target = hit.transform.GetComponent <TargetHit>(); if (target != null) { target.TakeDamage(damage); } } }