2
$\begingroup$

I want to make a character, which would move, and I want to use character physics and python for easyer controll. I know you get the character wrapper with wraper = bge.constraints.getCharacter(own) Then I want to make it move, but I can't figure out how walkDirection works. I did it like so:

import bge

cont = bge.logic.getCurrentController()
own = cont.owner

wraper = bge.constraints.getCharacter(own)
direction = (0, 1, 0)
wraper.walkDirection(direction)

But whnever I press the key and run the code I get an error: 'Vector' object not callable I can't find any examples of how that's done on the intrnet, and I tryed changing the code many times.

Please, can someone tell me how it's done? Thanks.

$\endgroup$

1 Answer 1

2
$\begingroup$

The wraper.walkDirection is a property of type Vector and not a function so you should do an assignment :

wraper.walkDirection = direction

to move in the local space orientation multiply the direction vector by the orientation matrix of the object :

direction = own.orientation*Vector((0, 0.1, 0))

you should include the Vector type by adding this line :

from mathutils import Vector
$\endgroup$
3
  • $\begingroup$ Thanks a lot. It works now. But is it possible to make the character move according to local rotation of the object (just like with applyMovement(x, y, z), Local) $\endgroup$
    – prok_8
    May 22, 2015 at 18:07
  • $\begingroup$ @RokiPodpecan Updated the answer to include this $\endgroup$
    – Chebhou
    May 22, 2015 at 18:30
  • $\begingroup$ @RokiPodpecan thanks , I have added that : ) $\endgroup$
    – Chebhou
    May 22, 2015 at 18:51

You must log in to answer this question.

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