I have an EditorCamera in my code and I was trying to set its initial rotation in a certain direction. I couldn't get it to work using .rotation, so I used the look_at method instead:
import ursina as ur
app = ur.Ursina(title="Cube")
ground = ur.Entity(model='quad', scale=60, texture='white_cube', texture_scale=(60, 60), rotation_x=90, y=-5, color=ur.color.light_gray)
cube = ur.Entity(model='cube', color=ur.color.black, position=(0, 0, 0), scale=(3, 3, 3))
ur.camera.position = 3, 3, -5
ur.EditorCamera()
ur.camera.look_at((1.5, 1.5, 1.5))
app.run()
This works, but if I use the mouse wheel to move forward/backward in the scene, the camera goes forward/backward on the z-axis, instead of relative to the camera looking direction. How do I fix this issue?
EDIT
Given @pokepetter's answer, I'm updating the code. The camera now moves correctly on zoom. However, I'm trying to place it to the right, above, and a bit in front of the cube and face the center of the cube. The result would hopefully be that it sees the cube's front-top-right corner at a roughly 45° angle, but I haven't been able to get it to do that:
app = ur.Ursina(title="Cube")
ground = ur.Entity(model='quad', scale=60, texture='white_cube', texture_scale=(60, 60), rotation_x=90, y=-5, color=ur.color.light_gray)
cube = ur.Entity(model='cube', texture='brick', color=ur.color.red, position=(1.5, 1.5, 1.5), scale=(3, 3, 3))
camera = ur.EditorCamera()
camera.position = 5, 5, -5
camera.look_at(cube)
# camera.look_at(cube.position)
# camera.look_at(ur.Vec3(1.5, 1.5, 1.5))
# camera.look_at(cube.bounds.center)
app.run()
Rotate the EditorCamera instead. EditorCamera parents the camera to itself, so it's moved relative to it. This mean the EditorCamera can rotate freely while all it has do to "zoom" is to change camera.z.
Example: