Quantcast
Channel: Questions in topic: "enemy"
Viewing all articles
Browse latest Browse all 1488

How to make a customizable variable in this script?

$
0
0
How do I make the damage to the player a customizable script as I want all melee enemies to use the same script but with different damage and it would take too much resources to duplicate and lightly modify the script for each enemy type. Here is the script: using System.Collections; using System.Collections.Generic; using UnityEngine; public class Mushroom_attack_script : MonoBehaviour { public Sprite sprite_attack; public SpriteRenderer spriteRenderer; public Sprite sprite_idle; void OnTriggerStay(Collider other) { //It will check for the name of the GameObject that had enter inside the enemy trigger if (other.gameObject.name == "FPSController") { HealthBarScript.health -= 0.0075f; } } void OnTriggerEnter(Collider other) { //It will check for the name of the GameObject that had enter inside the enemy trigger if (other.gameObject.name == "FPSController") { spriteRenderer.sprite = sprite_attack;// Change sprite } } void OnTriggerExit(Collider other) { //It will check for the name of the GameObject that had enter inside the enemy trigger if (other.gameObject.name == "FPSController") { spriteRenderer.sprite = sprite_idle;// Change sprite } } }

Viewing all articles
Browse latest Browse all 1488

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>