Notifications
bg
d
daniel4cd
London, United Kingdom
0
Likes
0
Followers
0
Connections
All
Articles0
Games0
Showcases0
Column0
Jobs0
Hi all, Please any help? I followed a tut to create an FPS and gun with animation (trigger) and sound (gun shot), and an enemy, but when the gun points to the enemy(cube) it disappears completely.

HandGumDamage script (Mechanics)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class HandGunDamage : MonoBehaviour
{
public int DamageAmount = 5;
public float TargetDistance;
public float AllowedRange = 25.0f;

// Update is called once per frame
void Update()
{

RaycastHit Shot;
if(Physics.Raycast (transform.position, transform.TransformDirection(Vector3.forward), out Shot))
{
TargetDistance = Shot.distance;

if(TargetDistance < AllowedRange)
{
Shot.transform.SendMessage("deductPoints", DamageAmount, SendMessageOptions.DontRequireReceiver);
}
}
}
}



// Enemy Script

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

public class EnemyScript : MonoBehaviour
{

public int EnemyHealth = 20;

void DeductPoints(int DamageAmount)
{
EnemyHealth -= DamageAmount;
}

// Update is called once per frame
void Update()
{
if (EnemyHealth <= 0)
{
Destroy(gameObject);
}
}


}

About Me
No description
See more
Skills
No skills added yet
Certifications (0)
Import
See all
daniel4cd's liked projects (0)
No likes yet
Following (0)
Not following anyone yet
Followers (0)
No followers
Following Companies (0)
Not following anyone yet