Vectors in Python

How do I create Vectors in python ?

px = self.pos.x;
py = self.pos.y;
v = Vector(px-target.pos.x, py-target.pos.y)
self.move({'x': px+v.x, 'y': py+v.y})

Apparently this dosen’t work.I tried adding the new keyword,that also dint help
I would like to know how to normalize them too

Vector isn’t support in Python yet. A workaround is to write your own Vector class for now.

I’ve opened an issue to track this problem:


distance = Vector.subtract(self.pos, yak) 


distance = Vector.subtract(yak, self.pos)

The first statement works correctly, the second shows an error (same place in the code). Why so?

I don’t know why any of those work, because yak would be a name or an id. Try to replace yak with yak.pos and they should be OK.

1 Like

Thanks, it worked. Guess I am very new to vectors