![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | The Asker |
I want to decrease the health of my player about one, if he is above a specific cell. And if he is above it i want to change it to another cell. I did it already, but the problem is that if my player is above this specific cell, the health decreases about 5 or 4. I thought it is because of the function “_process(delta)”. But i only decrease the health if the cell is 1 and directly after it i change the cell to 0. So if it runs again it should not decreas. Then i thought maybe the “_process(delta):” is faster than the update of the tilemap and now i am searching for a methode to update the tilemap dircetly after i changed the cell to 0.
My code:
func setTrace():
var tileMap = get_parent().get_node("traces")
var cellPos = tileMap.world_to_map(Vector2(position.x, position.y))
if tileMap.get_cellv(Vector2(cellPos.x / 4, cellPos.y / 4 + 0.4)) == 1:
health = health - 1
tileMap.set_cellv(Vector2(cellPos.x / 4, cellPos.y / 4 + 0.4), 0)
Cannot reproduce: your code works fine on my end. Can you provide an example project? Maybe the problem is somewhere else…
njamster | 2020-03-27 11:14