skinwalker
Member
Hi,
I have a projectile that must collide or skip collission with an object on the character layer based on if its friendly or not. I have a script called "Team" and I can easily check what team the object I'm colliding with is, but the problem is that I can't make that object go through or collide with it, its just one or the other.
For example if I make it collide then it will always collide no matter what the team is even if I do
The projectile is already "stuck" on the object when that OnCollission gets called. So I figured I should make it go through every object on the Character layer, but I need a way to make it collide and deal damage if its an enemy. Is there something like "OnPreCollission"?
EDIT: If I can somehow edit the last few lines of TrajectoryObject.cs's Cast method and add
Is there a way to do that without editing your code?
I have a projectile that must collide or skip collission with an object on the character layer based on if its friendly or not. I have a script called "Team" and I can easily check what team the object I'm colliding with is, but the problem is that I can't make that object go through or collide with it, its just one or the other.
For example if I make it collide then it will always collide no matter what the team is even if I do
protected override void OnCollision(RaycastHit? hit)
{
if (hit.HasValue && hit.Value.collider.name.Equals("Collider"))
{
Debug.Log("Check");
return;
}
if (m_ScheduledDeactivation != null)
{
SchedulerBase.Cancel(m_ScheduledDeactivation);
m_ScheduledDeactivation = null;
}
base.OnCollision(hit);
}
The projectile is already "stuck" on the object when that OnCollission gets called. So I figured I should make it go through every object on the Character layer, but I need a way to make it collide and deal damage if its an enemy. Is there something like "OnPreCollission"?
EDIT: If I can somehow edit the last few lines of TrajectoryObject.cs's Cast method and add
Code:
if (hitCount > 0)
{
m_RaycastHit = m_CombinedRaycastHits[index];
// TODO : Validate m_RaycastHit's value
return true;
}
return false;
Is there a way to do that without editing your code?
Last edited: