Hello, okay so what im trying to do is make a attack code that will randomize attack points(Attack points = how much life is lost) from what i gathered and already tried i using the Random.Range, that just takes random numbers off i didn’t want this i wanted something such as when the first hit is like -10 life, then the next -5 life, and so on, i was thinking of an array of numbers been called one after each other giving the effect of random life loss, without it actually been random, basicly so i have control of how much (LifePoints) i lose,
i wouldn’t know where to start, here is the code im using,
using UnityEngine;
using System.Collections;
public class Enemyattack : MonoBehaviour {
public GameObject target;
public float attackTimer;
public float coolDown;
// Use this for initialization
void Start ()
{
attackTimer = 0;
coolDown = 2.0f;
}
// Update is called once per frame
void Update ()
{
if(attackTimer > 0)
attackTimer -= Time.deltaTime;
if(attackTimer < 0)
attackTimer = 0;
if(attackTimer ==0){
Attack();
attackTimer = coolDown;
}
}
private void Attack(){
float distance = Vector3.Distance(target.transform.position, transform.position);
Vector3 dir = (target.transform.position - transform.position).normalized;
float direction = Vector3.Dot(dir, transform.forward);
if(distance < 4){
if(direction > 0){
Health eh = (Health)target.GetComponent("Health");
eh.AddjustCurrentHealth(-10);
}
}
}
}
If anyone could help please feel free to ![]()
Thanks