Hello, I’m having trouble with physics in Unity… Basically I have this carousel that’s supposed to spin with the duck on it, idk what I did, it was working before, but now it isn’t. Here’s a video , you can see all the important settings in it.
Basically, it’s supposed to starting spinning when the robot hits it, spin until the duck hits the bar and then falls off, but for some reason it’s going right through the bar. As you can see in the video, the bar has a collider, which is not a trigger, also the duck doesn’t seem to be moving properly, it’s bouncing around and not following the platform as it rotates.
Here’s my script,
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class rotateCarousel : MonoBehaviour
{
[SerializeField]Vector3 dir;
public bool hasDuck;
bool isSpinning;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
// transform.Rotate(0f, -50 * Time.deltaTime, 0f, Space.Self);
if (hasDuck && isSpinning)
{
transform.Rotate((dir * Time.deltaTime),Space.Self);
}
}
private void OnTriggerEnter(Collider collision)
{
if (collision.tag == "Spinner" && !isSpinning && hasDuck)
{
isSpinning = true;
}
}
private void OnCollisionStay(Collision collision)
{
if (collision.collider.tag == "Duck" && !hasDuck)
{
hasDuck = true;
}
}
private void OnCollisionExit(Collision collision)
{
if(collision.collider.tag == "Duck" && hasDuck)
{
hasDuck = false;
isSpinning = false;
}
}
}
I’ve also tried rigidbody.MoveRotation but that makes it even worse, at the slightest touch the duck will launch off.(btw, the only collision it’s detecting is the wheel thing on top of the robot which is a trigger, all other robot collisions are turned off)