I have a transformation (force applied moves object) happening initially, and then the user responds to it with the DownArrow. I want that initial transform.up to happen at random times within a set interval, and for that to loop over and over, so that the user can continue to respond to it.
using UnityEngine;
using System.Collections;
public class thingBumps : MonoBehaviour {
public float thrust;
public Rigidbody rb;
void Start() {
rb = GetComponent<Rigidbody>();
}
void FixedUpdate()
{
rb.AddForce (transform.up * thrust, ForceMode.Impulse);
if (Input.GetKey(KeyCode.DownArrow))
rb.AddForce(-transform.up * thrust,ForceMode.Impulse);
}
}
I have tried Coroutines and also InvokeRepeating but I am having a very hard time and I have read every thread on the topic. I just want that first transform.up to repeat at random time intervals so the user can continue to respond to it (with their own -transform.up transformation). Does anyone know how to do this?
I appreciate any advice.
Aucun commentaire:
Enregistrer un commentaire