I made a jelly softbody in Unity, and I've tried to make it bouncier (so that after an object lands on it, it bounces into the air higher than it does normally), but I can't seem to figure out how to do it. I've tried to alter every single aspect of the objects to bounce and the jelly itself that I could find, such as spring joint frequency, and rigidbody components for the softbody, but nothing made it bounce more from the jelly. I followed this tutorial: https://www.youtube.com/watch?v=3avaX00MhYc but made a center bone instead of using bones on opposite sides. Here are some screenshots of different aspects: https://i.stack.imgur.com/KWhUs.jpg This has been stumping me for the past week now, so I would appreciate any ideas.
Asked
Active
Viewed 660 times
0
-
Have you tried using a physics material? [Physics Material 3d](https://docs.unity3d.com/Manual/class-PhysicMaterial.html) [Physics Material 2d](https://docs.unity3d.com/Manual/class-PhysicsMaterial2D.html) – hijinxbassist Jul 27 '21 at 17:41
-
@hijinxbassist Yes, that changed nothing. What happens is when an object interacts with the softbody, it sinks in a little bit and then bounces back, but I want to increase the amount it sinks in and bounces back and I'm not sure how to do that. – Omega Productions Jul 27 '21 at 17:47
1 Answers
0
I've figured it out and it turns out I just needed to add force to the object to bounce OnCollisionExit with the softbody as well as add force to the softbody bones downwards OnCollisionEnter with an object so it still maintains the effect. Here's my code if anyone else would like to implement something like this into their game:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class jellyBounce : MonoBehaviour
{
public int speedBounce = 500;
public int speedInward = 500;
void OnCollisionEnter2D(Collision2D other)
{
if (other.gameObject.tag == "BounceMe")
{
speedInward = 300;
gameObject.GetComponent<Rigidbody2D> ().AddForce(Vector2.down*speedInward);
}
else if (other.gameObject.tag == "AlreadyBouncy")
{
speedInward = 50;
gameObject.GetComponent<Rigidbody2D>().AddForce(Vector2.down*speedInward);
}
}
void OnCollisionExit2D(Collision2D other)
{
if (other.gameObject.tag == "BounceMe")
{
speedBounce = 600;
other.gameObject.GetComponent<Rigidbody2D>().AddForce(Vector2.up*speedBounce);
}
else if (other.gameObject.tag == "AlreadyBouncy")
{
speedBounce = 100;
other.gameObject.GetComponent<Rigidbody2D>().AddForce(Vector2.up*speedBounce);
}
}
}