Bug in setWorldPosition? v2.1.18
Posted: Mon Jan 19, 2015 4:20 pm
Hi.
Problem: When using setWorldPosition the gameobject might get wrong x and y value depending on facing.
To recreate:
Create a north facing wall at 15,15 id=dungeon_wall_01_1. It's important that it's north facing for this to work/fail.
Run this code to move it up 1 elevation (1 elevation = 3 in world):
pos = dungeon_wall_01_1:getWorldPosition() dungeon_wall_01_1:setWorldPosition(pos[1], pos[2]+3, pos[3])
Visually this looks ok - the walls jump up 1 elevation.
However, if you look at print(dungeon_wall_01_1.y) it has become 14 (moving upwards shouldnt change y-value).
This may potentially cause collision problems if you are moving gameobjects with collision.
There are more problems like this:
if moving gameobject east then gameobjects faceing east gets +1 extra in x-value. Those facing north get -1y
moving north: face east +1x face north -1y
moving south: face east +1x face south +1y
moving west: face west -1x face north -1y
moving up: face north -1y face east +1x
moving down: face north -1y face east +1x
Is this a bug or am I missing something?
Problem: When using setWorldPosition the gameobject might get wrong x and y value depending on facing.
To recreate:
Create a north facing wall at 15,15 id=dungeon_wall_01_1. It's important that it's north facing for this to work/fail.
Run this code to move it up 1 elevation (1 elevation = 3 in world):
pos = dungeon_wall_01_1:getWorldPosition() dungeon_wall_01_1:setWorldPosition(pos[1], pos[2]+3, pos[3])
Visually this looks ok - the walls jump up 1 elevation.
However, if you look at print(dungeon_wall_01_1.y) it has become 14 (moving upwards shouldnt change y-value).
This may potentially cause collision problems if you are moving gameobjects with collision.
There are more problems like this:
if moving gameobject east then gameobjects faceing east gets +1 extra in x-value. Those facing north get -1y
moving north: face east +1x face north -1y
moving south: face east +1x face south +1y
moving west: face west -1x face north -1y
moving up: face north -1y face east +1x
moving down: face north -1y face east +1x
Is this a bug or am I missing something?