Describe the bug
I have created a rough projectile system in while an Actor is spawned in the player's location and then moves away in a relative position. This works fine when the player faces up and right, but not when the player faces down and left. I'm sure this is a coding error on my part, but I'd love to know where I've gone wrong.
To Reproduce
Steps to reproduce the behavior:
The code is being executed on the Scene level.
Expected behavior
For the projectile to move away from the player in the direction that the player is facing.
Platform (please complete the following information):
Additional context
Zip attached.
I think what's going on here is that the position values can only be between 0 and the length or height of the scene, and will wrap if it goes lower of higher. This means that, for a 32x32 scene, if the player is at position (15,0) and you set the relative position to (-16,0) the final calculated position will be (31,0) so the projectile will go to the right of the player instead of the intended left.
Sorry for the delay. Yes, this is correct. After reducing the distance that the projectile should move, everything works as intended. I wonder if there can be some sort of code that would ignore/bypass the wrapping functionality to make something like this more feasible.
Hey @timsamoff I've just pushed an update to the dev build with commit ab55a3ace7297ecf4bb92d332b00f728e28593db that seems to work.
As @pau-tomas says the issue is with the values wrapping around the scene so I've made it so that if the movement would cause an actor to wrap around the scene it now stops at the scene edge.
I've also increased the range you can use for the offset to be -31 to +31 so that you can shoot the projectile from the left edge of the scene all the way to the right edge.
If you increase the movement speed on the projectile and add a "Actor: Hide" event after the the conditional statements it's looking pretty good now!
Projectile 2.zip
Thanks, @chrismaltby!