I'm really new to unity and made this "game". As you can see in this video, the red ball rotates around the blue ones at contact, and when it leaves the screen the red ball resets to it's original position. Problem is that sometimes it gets stuck on the blue circles, which is shown in the video. My question isn't why it gets stuck, because I think I know where that problem might come from. I'm just wondering why it only gets stuck sometimes. Does it have to do with framerate maybe?
Without seeing how you coded it, we would just be taking guesses. You can paste your code here with code tags using the Code buttons in the toolbar. See the link in my signature.
Reason I didn't post my code was because I thought it would be something simple that doesn't have to do with any code. Anyway here's my code for the player/red ball: Code (CSharp): using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement; public class PlayerScript : MonoBehaviour { public float speed; public Rigidbody2D rigidbody; Vector3 direction = new Vector3(0,1,0); Vector3 targetPosition; public bool isMoving; void Start() { isMoving = true; rigidbody = GetComponent<Rigidbody2D>(); QualitySettings.vSyncCount = 0; Application.targetFrameRate = 60; } void Update() { if (Input.GetKeyDown(KeyCode.Space)) { Debug.Log("space"); isMoving = true; } if (isMoving) { direction.Normalize(); Vector3 position = transform.position; rigidbody.MovePosition(position + direction * speed * Time.deltaTime); } } public void Rotate(Vector3 originPosition, float rotatingSpeed) { if (!isMoving) { rigidbody.velocity = Vector3.zero; targetPosition = originPosition; direction = transform.position - targetPosition; transform.RotateAround(targetPosition, new Vector3(0, 0, 1), 1 * rotatingSpeed * Time.deltaTime); } } void OnBecameInvisible() { Destroy(gameObject); SceneManager.LoadScene("SampleScene"); } Here's the code for the blue balls: Code (CSharp): using System.Collections; using System.Collections.Generic; using UnityEngine; public class RotatingCircle : MonoBehaviour { public float rotatingSpeed; PlayerScript player; void Start() { player = FindObjectOfType<PlayerScript>(); } void Update() { Vector2 position = transform.position; transform.RotateAround(position, new Vector3(0,0,1), 1 * rotatingSpeed * Time.deltaTime); } void OnTriggerStay2D(Collider2D other) { player.Rotate(transform.position, rotatingSpeed); } void OnCollisionEnter2D(Collision2D other) { player.isMoving = false; Debug.Log("CollisionEnter2D"); } } Thanks!
So it looks like your blue ball OnTriggerStay function stops being called, which stops your player from rotating around it. That could be caused by the physics system separating the objects after a collision, which moves it out of range of the trigger. You may be able to solve this by increasing the size of the trigger.