python - Is it possible to parent to only one or two axes in Blender? -
i'm in process of creating 2d platformer using blender game engine. i'm having trouble getting camera follow character , keep him in center of screen. initially, tried parenting camera character, whenever character turns (rotates around z-axis 180 degrees), camera, making face of level. so, wondering if there way "parent" 1 or 2 axes of object another, or restrain axes moving if parented. way keep camera rotating, still have follow on y , z axes. 1 thing looked using python code. came with...
import bpy char = bpy.data.objects['hitbox'] obj = bpy.data.objects['camera'] obj.location.x = 69.38762 # set distance character camera obj.location.y = char.location.y obj.location.z = char.location.z bpy.data.scenes[0].update()
i realize need loop after assigning 'char' variable, can't python loops working run through entire game, 'while' loops crash bge. if either parenting issue, or python code, i'd appreciate it.
you need use bge
module, because game engine. problem is: used blender python, not bge python. try reach camera cam = bge.logic.getcurrentscene().active_camera
. ... should work:
import bge def main(): cam = bge.logic.getcurrentscene().active_camera obj = bge.logic.getcurrentcontroller().owner obj.worldposition.y = cam.worldposition.y obj.worldposition.z = cam.worldposition.z main()
(attach script 'hitbox' true triggered sensor can cycle forever.)
other solution: can try make vertex parent player.
Comments
Post a Comment