I want the object to follow the camera

from cospaces import *
import math
import random

car = scene.get_item(“ShGNYfhk”)

def object_move() :
car.transform.look_at(camera.transform.position )
car.transition.move_by(Vector3(0,0.1,0),0.1)
time.schedule(object_move, 0.1)

object_move()

The object moves along the camera at 0.1 second intervals.
The problem is that the object floats in the air and follows the camera.

img

How do I change the blocks in the photo to Python?

You can try this :point_down:

1 Like

Hi @jeny2026,

This code kind of works in Python, you can improve and adjust it to your needs.
Something similar is to be found in MBT-VXV

from cospaces import *
import math
import random

cam = scene.get_item("zIokIH5C")
car = scene.get_item("2D8DPxKu")
camplace = cam.transform.position

def object_move():
    global camplace
    car.animation.play_looping("Wheels turning")
    carlook()
    camplace = cam.transform.position - cam.transform.position/3
    car.transition.move_to(camplace,3)    
    update_distance()
           
def update_distance():
    time.schedule(object_move,3) 

def carlook():
    car.transform.look_at(cam.transform.position)

object_move()

Have a nice day!

3 Likes