I set up a camera to only move along the y axis. I want the camera to move with the player but only along the global y axis and ignore the rotation of the object it is following. I tried parenting the camera to the object and constraining the rotation and location, but the camera rotates with the object. none of the object constraints seem to work. I’ve also tried using game logic, but no luck.
Vertex parenting.
you can vertex parent a empty, then parent the camera to it, and then if you want to you can rotate the empty.
thank you both!
now I can’t figure out how to constrain the camera to the y axis. I tried using “add object constraint”, but those never seem to work in game. I also tried using game logic. any ideas?
ok so u want it to move with the player, and not rotate at all? U also want it to follow movement on Y only? no side to side or up and down?
if so use this code.
from bge import logic
from mathutils import Vector
cont = logic.getCurrentController()
own = cont.owner
obj = logic.getCurrentScene().objects
cam = obj[“Camera”]
cam_height = 3.0
cam.position = Vector(0.0, own.position[1], cam_height)