how do I make a sphere rotate around another sphere in ursina, python

298 Views Asked by At
from ursina import *

# update sphere_2 rotation
def update():
    line.rotation_y += 1
    sphere_2.rotation_y += 1

app = Ursina()
sphere_1 = Entity(model = 'sphere',scale = 2)
# try to make sphere_2 follow the lines rotation
line = Entity(model = 'line',scale = 4,y = -1)
sphere_2 = Entity(model = 'sphere',scale = 1,x = -2)
app.run()
1

There are 1 best solutions below

2
On

Parent sphere_2 to sphere_1. sphere_2.parent = sphere_1 to make position, rotation and scale relative to sphere_2. Or sphere_2.world_parent = sphere_1, if you want to keep the original transformation intact after parenting it.