We are making a game where you are a vendor for a bidet company and your first day is demonstrating the product at a convention. You (as the player) have to figure out a way to get the attention of show attendees in order to get buyers lined up.
I'm using Unity and I just started importing some standard assets and wrote two short scripts. Here they are in their current form:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Squirt : MonoBehaviour {
public Rigidbody droplet;
public GameObject nozzle;
public float waterForce=1f;
void Update () {
if (Input.GetButton ("Fire1") == true) {
Rigidbody drop;
drop=Instantiate(droplet, nozzle.transform.position, Quaternion.identity)as Rigidbody;
drop.velocity=nozzle.transform.TransformDirection(nozzle.transform.forward*waterForce);
}
}
}
and a teleporter for the ai Target once they reach it.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TeleportAiTarget : MonoBehaviour {
//I'm limiting the area that the Ai characters will want to walk towards.
public float xRange=8f;
public float zRange=8f;
float y;
Vector3 newPos;
public GameObject ai;
void Teleport(){
float x = Random.Range (-xRange, xRange);
float z = Random.Range (-zRange, zRange);
newPos = new Vector3 (x, y, z);
this.transform.position = newPos;
}
//When the Ai reaches the point I want them to wait for a moment before their target teleports to a new spot.
public float waitMax=5f;
float waitActual;
void OnTriggerEnter(Collider other){
if (other.gameObject == ai) {
waitActual = Random.Range (0f, waitMax);
cycle = waitActual;
waitingToTeleport = true;
}
}
// Use this for initialization
void Start () {
y = ai.transform.position.y;
}
//Just a timer
float timer;
float cycle;
bool waitingToTeleport;
void Update(){
if (waitingToTeleport == true) {
timer = timer + Time.deltaTime;
if (cycle < timer) {
Teleport ();
timer = 0f;
waitingToTeleport = false;
}
}
}
}
