Is there a way how to set up a camera that stays in one place and tracks an object with python?
I have tried this:
camera.getScreenPosition(player)
This doesn’t work.
Tracking a point in the world while moving the camera would be nice.
Is there a way how to set up a camera that stays in one place and tracks an object with python?
I have tried this:
camera.getScreenPosition(player)
This doesn’t work.
Tracking a point in the world while moving the camera would be nice.
Use a Tracking actuator to make it look towards the object.
You can set the tracking target in Python if needed.
Get a vector from the camera to the object. Align the camera along the -Z to that vector. You’ll probably need to align the camera up and down(Y axis) otherwise it might be upside down or angled funny.
A tracking actuator? Which one is that? Do you mean the Camera actuator?
That one follows the object and I want the camera to look at object or a point on a map.
Thank you for the suggestion, how can you set that up with python?
Sorry, it’s one of the options in the “Edit Object” actuator. It’s called “Track to”.
OK this does work thank you.
But if I wanted a point on a world position instead of an object.
How would I do that? Especially in python.
Personally, I usually just use an empty. Have the camera track the empty and use Python to set the empty’s position to whatever co-ordinates you want.
If you don’t want to do that, then you’d need to maths it with sodsm_live’s Python solution.
You are right. I have created an empty which I’m moving to a designated place.
This is the best solution.