- Home /
Question by
OnlySpace_unity · Aug 03, 2020 at 11:25 AM ·
c#raycastprogrammingraycasthitdamage
I'm trying to get a Raycast Laser weapon to tell whatever it hits to do damage, and its not working. im kindof a noob...
Public Void FileLazer(Vector3 targetPosition, Transform.target = null)
{
if(canFire)
{
if(target != null)
{
SpawnExplosin(targetPosition, target);
FighterSheilds health = hit.collider.GetComponent<FighterSheilds>();
Sheild playerHealth = hit.collider.GetComponent<Sheild>();
FrigateHull frigateHull = hit.collider.GetComponent<FrigateHull>;
if ( health != null)
{
health.fighterTakeDamage (smallLazerDamage);
Debug.Log("damage dealt")
}
else
if ( playerHealth != null)
{
playerHealth.TakeDamage (smallLazerDamage);
}
else
if ( frigateHull != null)
{
frigateHull.frigateDamage (smallLazerDamage);
}
return hit.point.
Comment