Balloon float upwards mechanic.
Hi, wanna know how to make a balloon go JUST upwards for my game. And when it touches the ceiling the game's over
Answer by qcha0s · Feb 01, 2017 at 09:52 PM
Add a Rigidbody to the balloon game object and turn off gravity. In a script attached to the balloon. Add ...
public float floatStrength = 3.5f; // change to your liking
Then in FixedUpdate, Add ...
GetComponent<Rigidbody>().AddForce(Vector3.up * floatStrength);
I would name the object, "balloon" perhaps and put a collider on the ceiling that checks the name of the colliding object to end the game.
Hope that helps.
R.
Answer by LightSource · Jul 19, 2016 at 03:16 AM
At the beginning of your game, I would use Rigidbody.AddForce() to make it float upward. You can then use OnCollisionEnter to detect collision with the ceiling.
https://docs.unity3d.com/ScriptReference/Rigidbody.AddForce.html https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnCollisionEnter.html
Answer by Underpig1 · Mar 28, 2020 at 03:45 AM
You could also add a Constant Force component to ensure it rises directly upwards. https://docs.unity3d.com/Manual/class-ConstantForce.html
Your answer
![](https://koobas.hobune.stream/wayback/20220612085106im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to implement a firebreathing mechanic in a 2D scroller 0 Answers
How do i create a return function for my shooting mechanic? 0 Answers
ingame weapon creator 0 Answers
Unity VR: Arm Position Trigger Event HELP,Unity VR: Arm position trigger Event help 0 Answers
Button Registering twice when pressed 0 Answers