How do I…
Make it so even after my sprite collected all the wood from a tree, it goes to another tree to cut it down too and so on
What is the actual result
it just sits there
Make it so even after my sprite collected all the wood from a tree, it goes to another tree to cut it down too and so on
it just sits there
If the tree is still in the scene then currently it’s going to go towards the tree instance that was added to the scene first.
To move to another tree, you would need to add a condition to ignore the cutdown trees. You could check the health or the animation. I would also use the pick nearest object so it doesn’t just go to the next oldest object.
The event that stops the character also needs a trigger once otherwise it’s going to keep stopping the object while it’s in collision.
Instead of using force. You could tween to the next tree or use the pathfinder. Then instead of checking for collision to stop the character it would stop automatically.
Hey, im pretty sure i’ve done what you told me to, this is what i did:
When I press z one time, it goes to a tree and cuts it down, but then it doesn’t do anything until I press z another time. When I press it again, it goes to another tree but doesn’t do any damage to it.
If you click it multiple times (2+) it starts to do weird stuff, I don’t know how to explain it, you can go here gd.games game build to see it
If I didn’t do the code proprely, let me know what I did wrong
If you’re still using this, it has a trigger once. So, the first cut tree might prevent it from triggering again.
This is how I might do it. I added linking so you don’t need to check the collision. The issue is that multiple trees might be in collision with the cutter. I also added a point to position the cutter near the base of the tree. It also checks if the tween exists before going to the next tree.
You could add subevents to change the animation for the other health levels.
I also calculated the time based on distance to make the object move at the same speed regardless of the distance. It just adds consistency. You can adjust the speed by changing the number 200
If the tree regrows, you might still need the existing events to handle that.
Okay, that works a lot better, thank you so much for the help :DD