-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbubly flame thrower.cs
30 lines (24 loc) · 1012 Bytes
/
bubly flame thrower.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#a unity script it should on button f shoot bubble particle that act like a flame thrower that makes things float and play a song and then make you fly ina weird floaty way in game
using UnityEngine;
using System.Collections;
public class BubbleParticleScript : MonoBehaviour {
public ParticleSystem bubbleParticles;
public AudioClip song;
public float bubbleForce = 10.0f;
public float playerFlyForce = 100.0f;
private bool isPlayingSong = false;
void Update () {
if (Input.GetKeyDown(KeyCode.F)) {
bubbleParticles.Play();
Rigidbody rb = GetComponent<Rigidbody>();
rb.AddForce(transform.forward * bubbleForce, ForceMode.Impulse);
if (!isPlayingSong) {
AudioSource audio = GetComponent<AudioSource>();
audio.clip = song;
audio.Play();
isPlayingSong = true;
}
rb.AddForce(Vector3.up * playerFlyForce, ForceMode.Impulse);
}
}
}