As highlighted in this video : https://www.youtube.com/watch?v=qr5ySpRrnLo
I have an issue with the big version of my rotating objects. The small one, rotating at the same speed seem to work perfectly. The big one just goes through the player. I tried using different type of Collision Detection, living them as the default… tried to update the Physics settings but nothing seems to work.
Both the rotating object and my player are moved in FixedUpdate.
Does anyone have any idea as to how to fixe this issue?
Here is my rotating object’s script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Spinner : MonoBehaviour
{
[SerializeField] float spinSpeed;
void FixedUpdate()
{
transform.Rotate
(
transform.rotation.x,
-spinSpeed * Time.deltaTime,
transform.rotation.z
);
}
}
And here is the one for my player:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
public class Mover : MonoBehaviour
{
[SerializeField] float moveSpeed = 1;
Vector2 moveInput;
Rigidbody myRigidBody;
void Start()
{
myRigidBody = GetComponent<Rigidbody>();
}
void FixedUpdate()
{
Move();
}
void OnMove(InputValue value)
{
moveInput = value.Get<Vector2>();
}
void Move()
{
Vector3 playerVelocity = new Vector3
(
moveInput.x * moveSpeed * Time.deltaTime,
myRigidBody.velocity.y,
moveInput.y * moveSpeed * Time.deltaTime
);
myRigidBody.velocity = playerVelocity;
}
}