0
$\begingroup$

AttributeError: KX_GameObject.worldLinearVelocity is missing a physics controller

This module stops running when it meets the "cam.worldLinearVelocity" command keys. It used to run before I parent the camera to an empty and the empty to the vertices of a cube.

In the lines where the error occurs I changed the camera speed so the camera would move accordingly when the mouse cursor would be near the edges of the screen.

Below are 2 pictures to clear things a bit and the module itself.

cam logic bricks empty logic bricks (even if I change the empty and the cube player into dynamic or static nothing changed, same error)

import bge

bge.render.showMouse(True)

scene = bge.logic.getCurrentScene()

cont = bge.logic.getCurrentController()
sens_wh_up = cont.sensors["wh_up"]
sens_wh_down = cont.sensors["wh_down"]
cam = scene.active_camera

mousePos = bge.logic.mouse.position
mX = max(0.0,min(1.0,mousePos[0]))
mY = max(0.0,min(1.0,mousePos[1]))

if mX < 0.05:
    cam.worldLinearVelocity.x = -5*(2-mX)
    cam.worldLinearVelocity.y = (0.5-mY)*5
elif mX > 0.95:
    cam.worldLinearVelocity.x = 5*(2+mX)
    cam.worldLinearVelocity.y = (0.5-mY)*5

if mY < 0.05:
    cam.worldLinearVelocity.y = 5*(2+mY)
    cam.worldLinearVelocity.x = -(0.5-mX)*5
elif mY > 0.95:
    cam.worldLinearVelocity.y = -5*(2-mY)
    cam.worldLinearVelocity.x = -(0.5-mX)*5

cam.worldLinearVelocity *= 0.9


if (sens_wh_up.positive):
    cam.ortho_scale = cam.ortho_scale+5
if (sens_wh_down.positive):
    cam.ortho_scale = cam.ortho_scale-5

What am I doing wrong? What exactly is the physics controller that I am missing?

$\endgroup$
4
  • $\begingroup$ This question is Way too unclear to be able to tell whether or not it is a bug report, or if it is just a mistake. $\endgroup$ Commented Apr 19, 2015 at 22:38
  • $\begingroup$ @Lev a sample file would be helpful here $\endgroup$
    – Chebhou
    Commented Apr 20, 2015 at 10:24
  • $\begingroup$ @Chebhou there you go,should have done it from the start. pasteall.org/blend/35677 $\endgroup$
    – Lev
    Commented Apr 20, 2015 at 10:58
  • $\begingroup$ I tried with cam.setLinearVelocity() no errors but no success $\endgroup$
    – Chebhou
    Commented Apr 20, 2015 at 13:02

1 Answer 1

1
$\begingroup$

If you parent a physics object to another object it becomes a static object. Therefore there is no velocity anymore.

It was answered to me in another forum.Thanks for all the effort.I 'll mark it answered if I find how.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .