sheep – ARTech
For the tech demo, I essentially got a capsule, representing a ghost, to move towards any gameobjects that have the tag “object.” I was working on repulsion but I didn’t get it done yet. My plan is to have the ghost spawn at one of the points and then you move the point itself, to get close enough to a capsule. I was able to figure out how to have multiple image targets appear on the cards.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Body : MonoBehaviour {
public float forceAmount = 0;
// Use this for initialization
void Start () {
foreach (GameObject obj in GameObject.FindGameObjectsWithTag("obj")) {
float make = Random.Range (0f, 1f);
print (make);
/*
if (make < 0.5f) {
obj.GetComponent ().attract = false;
obj.GetComponent ().material.color = Color.red;
}
*/
//if (make >= 0.5f) {
obj.GetComponent ().attract = true;
obj.GetComponent ().material.color = Color.blue;
//}
}
}
// Update is called once per frame
void Update () {
foreach (GameObject obj in GameObject.FindGameObjectsWithTag("obj")) {
if (obj.GetComponent ().attract == true) {
Vector3 direction = (obj.transform.position - transform.position).normalized;
GetComponent ().AddRelativeForce (direction * forceAmount);
}
if (obj.GetComponent ().attract == false) {
Vector3 direction = (obj.transform.position - transform.position).normalized;
GetComponent ().AddRelativeForce (direction * forceAmount);
}
}
}
}