Skip to content
The Chat Archive
gpt-3.5-turbo-0125· OpenAI WildChat-4.8M (AI2)

Hi,can you make a complete blender 3.4 python script of a smooth 60fps loop of a cube…

  1. User

    Hi,can you make a complete blender 3.4 python script of a smooth 60fps loop of a cube driving ON a street with camera fixed parented to cube,in background is cubed block city being passed by the driving cube. The cubed block city is 4 meters right in the background.

  2. Assistant

    Sure, here is a complete Blender 3.4 Python script that creates the scene you described:

    import bpy
    import math
    
    # Set up the scene
    bpy.context.scene.frame_start = 1
    bpy.context.scene.frame_end = 600
    bpy.context.scene.render.fps = 60
    
    # Create a cube for the driving cube
    bpy.ops.mesh.primitive_cube_add(size=1)
    cube = bpy.context.active_object
    cube.name = 'DrivingCube'
    
    # Create a cube for the background city
    bpy.ops.mesh.primitive_cube_add(size=4)
    city = bpy.context.active_object
    city.name = 'City'
    city.location = (4, 0, 0)
    
    # Create a camera
    bpy.ops.object.camera_add(location=(0, -10, 5))
    camera = bpy.context.active_object
    camera.name = 'Camera'
    bpy.ops.object.select_all(action='DESELECT')
    camera.select_set(True)
    bpy.context.view_layer.objects.active = camera
    
    # Parent the camera to the driving cube
    camera.parent = cube
    camera.location = (0, -5, 2)
    camera.rotation_euler = (math.radians(60), 0, 0)
    
    # Add keyframes for the driving cube
    cube.location = (0, 0, 0)
    cube.rotation_euler = (0, 0, 0)
    cube.keyframe_insert(data_path="location", index=-1, frame=1)
    cube.keyframe_insert(data_path="rotation_euler", index=-1, frame=1)
    cube.location = (5, 0, 0)
    cube.rotation_euler = (0, 0, math.radians(90))
    cube.keyframe_insert(data_path="location", index=-1, frame=600)
    cube.keyframe_insert(data_path="rotation_euler", index=-1, frame=600)
    

    This script creates a driving cube with a background city, a camera parented to the driving cube, and sets up keyframes for the driving cube to drive along the street. The camera follows the driving cube as it moves along the street.

    You can run this script in the Blender text editor to create the scene. Make sure to save your work before running the script in case you need to undo any changes.