I am trying to write a script where if the player pressed down on the mouse, a Boolean called “Hover” would equal yes. If the player object was “hovering” while in collision with my particle system, the player would rise in the y axis. However I get a namespace error on ParticleCollsionEvent which is weird since I’m adapting code from the Unity documentation page: Unity - Scripting API: MonoBehaviour.OnParticleCollision(GameObject) In addition, I’m also getting parsing and unexpected symbol errors which I’m not sure how to fix. Here is what I have so far:
using UnityEngine;
using System.Collections;
public class HoverScript : MonoBehaviour {
public float Hoverforce;
public ParticleSystem part;
public ParticleCollisionEvent[] collisionEvents;
public bool Hover;
// Use this for initialization
void Start () {
part = GetComponent<ParticleSystem>();
collisionEvents = new ParticleCollisionEvent[16];
}
// Update is called once per frame
void Update () {
if (Input.GetKeyDown ("mouse0"))
Hover = true;
}
void OnParticleCollison (GameObject other) {
int safeLength = part.safeCollisionEventSize;
if (collisionEvents.Length < safeLength)
collisionEvents = new ParticleCollisionEvent[safeLength];
int numCollisionEvents = part.GetCollisionEvents(other, collisionEvents);
int i = 0;
while (i < numCollisionEvents && Hover = true) {
other.rigidbody.AddForce(Vector3.up * Hoverforce, ForceMode.Acceleration);
}
i++;
}
}
Any advice would be useful thanks!