- Home /
Question by
Kingsmario · Jun 19, 2019 at 04:33 PM ·
orbitspin
how to make objects to spin(orbit) around a point on 2 axes?
i want to make this level , but i can not find a script to spin objects around a point on both axes, but only on one. here is what i have: https://imgur.com/a/jpMvYly
Comment
Best Answer
Answer by Yeezyy · Jun 19, 2019 at 05:13 PM
You can just parent it to the first object or attach this script to the 2 object with the same value
using UnityEngine;
public class Rotator : MonoBehaviour
{
[SerializeField]
private float speed = 10.0f;
[Range(-1,1)]
[SerializeField]
private int direction = -1;
[SerializeField]
private Vector3 axis = Vector3.up;
[SerializeField]
private float angle = 10.0f;
// Update is called once per frame
private void Update()
{
transform.rotation *= Quaternion.Euler( axis * angle * speed * Time.deltaTime * direction) ;
}
}
Your answer
![](https://koobas.hobune.stream/wayback/20220612203456im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Player movement against skybox 0 Answers
Third Person Camera Orbit 0 Answers
Making my camera script snap back to original position 1 Answer
How do you move multiple objects in an orbit? 1 Answer
2D Topdown deteriorating orbit? 1 Answer