Created
February 2, 2019 22:22
-
-
Save Fintan/56bf5617568c054410bb2b0b685254cb to your computer and use it in GitHub Desktop.
add tracking camera at cursor in Blender
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import bpy | |
| cursorLoc = bpy.context.scene.cursor_location | |
| # create camera at cursor | |
| cam = bpy.data.cameras.new("Camera") | |
| cam_ob = bpy.data.objects.new("Camera", cam) | |
| cam_ob.location = cursorLoc | |
| # add to default collection | |
| col = bpy.data.collections['Collection'] | |
| col.objects.link(cam_ob) | |
| # track camera to default cube | |
| trackCube = cam_ob.constraints.new("TRACK_TO") | |
| trackCube.track_axis = "TRACK_NEGATIVE_Z" | |
| trackCube.up_axis = "UP_Y" | |
| trackCube.target = bpy.data.objects['Cube'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment