Script which control tilt of car - crash, why?

I am trying to write script which control tilt of my car. Tilt is depended from speed and difference between angle of car and front wheel.

Why my script makes blender crash and how fix it?


  • import bpy
  • import math
  • def pochyl(klatka):
  • speedobj='Car_Rig'
  • fps=25
  • x=bpy.context.scene.objects[speedobj].matrix_world.to_translation().x
  • y=bpy.context.scene.objects[speedobj].matrix_world.to_translation().y
  • z=bpy.context.scene.objects[speedobj].matrix_world.to_translation().z
  • x2=bpy.context.scene.objects[speedobj].matrix_world.to_translation().x
  • y2=bpy.context.scene.objects[speedobj].matrix_world.to_translation().y
  • z2=bpy.context.scene.objects[speedobj].matrix_world.to_translation().z
  • odleglosc=math.sqrt( pow(x2-x,2) + pow(y2-y,2) + pow(z2-z,2))
  • predkosc=odleglosc*fps*3.6
  • kat=bpy.context.scene.objects['Felga'].matrix_world.to_euler().z - bpy.context.scene.objects[speedobj].matrix_world.to_euler().z
  • pochylenie=(predkosc*0.01)*kat
  • <b>print</b>(pochylenie)
  • <b>return</b> pochylenie



blend file:

Does it give any tracebacks in the terminal?

ok, I quess I found the issue. My function is infinity looped.