Hello, I am trying to pass a variable into a function but I am not sure what the variable should be. If you reference my code I am trying to pass the var movement variable to my IEnumerator slowMoveTime function. Thanks for the help.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class slowMovement : MonoBehaviour {
public int damage;
public float time;
public float speed;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void OnTriggerEnter (Collider col) {
if (col.GetComponent<Collider>().tag == "LocalPlayer") {
Debug.Log ("hit the remoteplayer");
var hit = col.gameObject;
var health = hit.GetComponent<Health> ();
var movement = hit.GetComponent<PlayerController> ();
if (health != null) {
health.TakeDamage (damage);
}
if (movement != null) {
movement.speed = speed;
StartCoroutine(slowMoveTime (time, movement));
}
Destroy (gameObject);
}
}
IEnumerator slowMoveTime (float time,"what goes here" movement) {
yield return new WaitForSeconds (time);
}
}