Can't damage the enemies or boxes in the 3D Game Kit

I can’t damage the enemies or even destroy the destructible boxes, they all are on the enemy layer and i have the enemy layer selected as targel layer on the staff, but it just goes right through them.

Proberly because of how you have adjusted the physics collision matrix. Unity - Manual: Layer-based collision detection Make all the layers are ticked for the ones you want to collide with the other layers. If this is not the case, I need more information to help you solve the problem.

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace Gamekit3D
{
    public class MeleeWeapon : MonoBehaviour
    {
        public int damage = 1;

        [System.Serializable]
        public class AttackPoint
        {
            public float radius;
            public Vector3 offset;
            public Transform attackRoot;

#if UNITY_EDITOR
            //editor only as it's only used in editor to display the path of the attack that is used by the raycast
            [NonSerialized] public List<Vector3> previousPositions = new List<Vector3>();
#endif

        }

        public ParticleSystem hitParticlePrefab;
        public LayerMask targetLayers;

        public AttackPoint[] attackPoints = new AttackPoint[0];

        public TimeEffect[] effects;

        [Header("Audio")] public RandomAudioPlayer hitAudio;
        public RandomAudioPlayer attackAudio;

        public bool throwingHit
        {
            get { return m_IsThrowingHit; }
            set { m_IsThrowingHit = value; }
        }

        protected GameObject m_Owner;

        protected Vector3[] m_PreviousPos = null;
        protected Vector3 m_Direction;

        protected bool m_IsThrowingHit = false;
        protected bool m_InAttack = false;

        const int PARTICLE_COUNT = 10;
        protected ParticleSystem[] m_ParticlesPool = new ParticleSystem[PARTICLE_COUNT];
        protected int m_CurrentParticle = 0;

        protected static RaycastHit[] s_RaycastHitCache = new RaycastHit[32];
        protected static Collider[] s_ColliderCache = new Collider[32];

        private void Awake()
        {
            if (hitParticlePrefab != null)
            {
                for (int i = 0; i < PARTICLE_COUNT; ++i)
                {
                    m_ParticlesPool *= Instantiate(hitParticlePrefab);*

m_ParticlesPool*.Stop();
_
}_
_
}_
_
}*_

private void OnEnable()
{

}

//whoever own the weapon is responsible for calling that. Allow to avoid “self harm”
public void SetOwner(GameObject owner)
{
m_Owner = owner;
}

public void BeginAttack(bool thowingAttack)
{
if (attackAudio != null)
attackAudio.PlayRandomClip();
throwingHit = thowingAttack;

m_InAttack = true;

m_PreviousPos = new Vector3[attackPoints.Length];

for (int i = 0; i < attackPoints.Length; ++i)
{
Vector3 worldPos = attackPoints*.attackRoot.position +*
attackPoints_.attackRoot.TransformVector(attackPoints*.offset);*_
m_PreviousPos = worldPos;

#if UNITY_EDITOR
attackPoints*.previousPositions.Clear();*
attackPoints.previousPositions.Add(m_PreviousPos*);
_#endif*
}
}_

public void EndAttack()
{
m_InAttack = false;

#if UNITY_EDITOR
for (int i = 0; i < attackPoints.Length; ++i)
{
attackPoints*.previousPositions.Clear();*
}
#endif
}

private void FixedUpdate()
{
if (m_InAttack)
{
for (int i = 0; i < attackPoints.Length; ++i)
{
AttackPoint pts = attackPoints*;*

Vector3 worldPos = pts.attackRoot.position + pts.attackRoot.TransformVector(pts.offset);
Vector3 attackVector = worldPos - m_PreviousPos*;*

if (attackVector.magnitude < 0.001f)
{
// A zero vector for the sphere cast don’t yield any result, even if a collider overlap the “sphere” created by radius.
// so we set a very tiny microscopic forward cast to be sure it will catch anything overlaping that “stationary” sphere cast
attackVector = Vector3.forward * 0.0001f;
}

Ray r = new Ray(worldPos, attackVector.normalized);

int contacts = Physics.SphereCastNonAlloc(r, pts.radius, s_RaycastHitCache, attackVector.magnitude,
~0,
QueryTriggerInteraction.Ignore);

for (int k = 0; k < contacts; ++k)
{
Collider col = s_RaycastHitCache[k].collider;

if (col != null)
CheckDamage(col, pts);
}

m_PreviousPos = worldPos;

#if UNITY_EDITOR
pts.previousPositions.Add(m_PreviousPos*);
_#endif*
}
}
}_

private bool CheckDamage(Collider other, AttackPoint pts)
{
Damageable d = other.GetComponent();
if (d == null)
{
return false;
}

if (d.gameObject == m_Owner)
return true; //ignore self harm, but do not end the attack (we don’t “bounce” off ourselves)

if ((targetLayers.value & (1 << other.gameObject.layer)) == 0)
{
//hit an object that is not in our layer, this end the attack. we “bounce” off it
return false;
}

if (hitAudio != null)
{
var renderer = other.GetComponent();
if (!renderer)
renderer = other.GetComponentInChildren ();
if (renderer)
hitAudio.PlayRandomClip (renderer.sharedMaterial);
else
hitAudio.PlayRandomClip ();
}

Damageable.DamageMessage data;

data.amount = damage;
data.damager = this;
data.direction = m_Direction.normalized;
data.damageSource = m_Owner.transform.position;
data.throwing = m_IsThrowingHit;
data.stopCamera = false;

d.ApplyDamage(data);

if (hitParticlePrefab != null)
{
m_ParticlesPool[m_CurrentParticle].transform.position = pts.attackRoot.transform.position;
m_ParticlesPool[m_CurrentParticle].time = 0;
m_ParticlesPool[m_CurrentParticle].Play();
m_CurrentParticle = (m_CurrentParticle + 1) % PARTICLE_COUNT;
}

return true;
}

#if UNITY_EDITOR

private void OnDrawGizmosSelected()
{
for (int i = 0; i < attackPoints.Length; ++i)
{
AttackPoint pts = attackPoints*;*

if (pts.attackRoot != null)
{
Vector3 worldPos = pts.attackRoot.TransformVector(pts.offset);
Gizmos.color = new Color(1.0f, 1.0f, 1.0f, 0.4f);
Gizmos.DrawSphere(pts.attackRoot.position + worldPos, pts.radius);
}

if (pts.previousPositions.Count > 1)
{
UnityEditor.Handles.DrawAAPolyLine(10, pts.previousPositions.ToArray());
}
}
}

#endif
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using Gamekit3D.Message;
using UnityEngine.Serialization;

namespace Gamekit3D
{
public partial class Damageable : MonoBehaviour
{

public int maxHitPoints;
[Tooltip(“Time that this gameObject is invulnerable for, after receiving damage.”)]
public float invulnerabiltyTime;

[Tooltip(“The angle from the which that damageable is hitable. Always in the world XZ plane, with the forward being rotate by hitForwardRoation”)]
[Range(0.0f, 360.0f)]
public float hitAngle = 360.0f;
[Tooltip(“Allow to rotate the world forward vector of the damageable used to define the hitAngle zone”)]
[Range(0.0f, 360.0f)]
[FormerlySerializedAs(“hitForwardRoation”)] //SHAME!
public float hitForwardRotation = 360.0f;

public bool isInvulnerable { get; set; }
public int currentHitPoints { get; private set; }

public UnityEvent OnDeath, OnReceiveDamage, OnHitWhileInvulnerable, OnBecomeVulnerable, OnResetDamage;

[Tooltip(“When this gameObject is damaged, these other gameObjects are notified.”)]
[EnforceType(typeof(Message.IMessageReceiver))]
public List onDamageMessageReceivers;

protected float m_timeSinceLastHit = 0.0f;
protected Collider m_Collider;

System.Action schedule;

void Start()
{
ResetDamage();
m_Collider = GetComponent();
}

void Update()
{
if (isInvulnerable)
{
m_timeSinceLastHit += Time.deltaTime;
if (m_timeSinceLastHit > invulnerabiltyTime)
{
m_timeSinceLastHit = 0.0f;
isInvulnerable = false;
OnBecomeVulnerable.Invoke();
}
}
}

public void ResetDamage()
{
currentHitPoints = maxHitPoints;
isInvulnerable = false;
m_timeSinceLastHit = 0.0f;
OnResetDamage.Invoke();
}

public void SetColliderState(bool enabled)
{
m_Collider.enabled = enabled;
}

public void ApplyDamage(DamageMessage data)
{
if (currentHitPoints <= 0)
{//ignore damage if already dead. TODO : may have to change that if we want to detect hit on death…
return;
}

if (isInvulnerable)
{
OnHitWhileInvulnerable.Invoke();
return;
}

Vector3 forward = transform.forward;
forward = Quaternion.AngleAxis(hitForwardRotation, transform.up) * forward;

//we project the direction to damager to the plane formed by the direction of damage
Vector3 positionToDamager = data.damageSource - transform.position;
positionToDamager -= transform.up * Vector3.Dot(transform.up, positionToDamager);

if (Vector3.Angle(forward, positionToDamager) > hitAngle * 0.5f)
return;

isInvulnerable = true;
currentHitPoints -= data.amount;

if (currentHitPoints <= 0)
schedule += OnDeath.Invoke; //This avoid race condition when objects kill each other.
else
OnReceiveDamage.Invoke();

var messageType = currentHitPoints <= 0 ? MessageType.DEAD : MessageType.DAMAGED;

for (var i = 0; i < onDamageMessageReceivers.Count; ++i)
{
var receiver = onDamageMessageReceivers as IMessageReceiver;
receiver.OnReceiveMessage(messageType, this, data);
}
}

void LateUpdate()
{
if (schedule != null)
{
schedule();
schedule = null;
}
}

#if UNITY_EDITOR
private void OnDrawGizmosSelected()
{
Vector3 forward = transform.forward;
forward = Quaternion.AngleAxis(hitForwardRotation, transform.up) * forward;

if (Event.current.type == EventType.Repaint)
{
UnityEditor.Handles.color = Color.blue;
UnityEditor.Handles.ArrowHandleCap(0, transform.position, Quaternion.LookRotation(forward), 1.0f,
EventType.Repaint);
}

UnityEditor.Handles.color = new Color(1.0f, 0.0f, 0.0f, 0.5f);
forward = Quaternion.AngleAxis(-hitAngle * 0.5f, transform.up) * forward;
UnityEditor.Handles.DrawSolidArc(transform.position, transform.up, forward, hitAngle, 1.0f);
}
#endif
}

}

Olá, boa tarde!

Eu não entendi muito bem seu problema.
Mas, verifique se as camadas do projeto estão tendo conexão, independentemente se as caixas “possuem” colisão normal ou trigger.
Para checar se existe colisão entre os "gameobjects ", verifique no menu Edit - > Project Settings → Physics (para 3D) ou Physics (para 2D)

Hey, @Ze_Bomba97 did you find any solutions to this question? I’m having the exact same problem right now and it is very frustrating.