So I did this:
X Pos = X Pos + (speed*Cos(angle))
Y Pos = Y Pos - (speed*Sin(angle))
Only, now the diagonals aren't working right. As in the speeds are different, or rather slower, somehow than traveling strictly horizontally or vertically.
So I did this:
X Pos = X Pos + (speed*Cos(angle))
Y Pos = Y Pos - (speed*Sin(angle))
Only, now the diagonals aren't working right. As in the speeds are different, or rather slower, somehow than traveling strictly horizontally or vertically.
You have to store your Xpos and Ypos as alt. values and operate sin-cos calculations on that,
X and Y object's positions are pixel integers and won't work well with decimal operators (sin_cos)
start of frame >>
set Xpos_Val to X position
set Ypos_Val to Y position
on movement >>
set Xpos_Val to Xpos_Val + (speed*Cos(angle))
set Ypos_Val to Ypos_Val - (speed*Sin(angle))
set X position to Xpos_Val
set Yposition to Ypos_Val
That actually worked out quite well!
Now, however, the Move Safely thing gets stuck in walls, likely from attempting to read from X and Y values that have decimal points associated with them.
Got it all to work perfectly now, though I'm scared to think of how multiple objects will work.
Move Safely has no issues with floating point movements, why would multiple objects be hard to implement? If you're storing the X/Y values in a value of the object you're moving, each object will be independent.
It's just that I'm going to be putting this to use in a game with some complicated movement and obstacle management. Move Safely crashes on me when I mess around with it, trying to understand how to put it to use, so it's just the daunting task I have ahead of me that I'm not so keenly looking forward to.
I wonder if there's an example around that uses the object extensively so I can see how it works when it comes to needing to check for collisions on multiple things (walls, projectiles, other enemies, jump plates, etc).
I'd like to see an extensive example of Move Safely as well...
EDIT: actually, I think i realize now that this component doesn't MOVE the object, but only checks for collisions during a move...
I think it does that as well. I had tried something similar to it within code itself to try to keep collisions working right, where X and Y position were preserved while not overlapping an obstacle, and then an event further down where if the object was overlapping an obstacle, it'd set the X and Y positions back. Of course it didn't go as planned, which is why I'm looking into this object now. Problem is, I'd like to use it with objects that'd have a number of different movement types and collision circumstances, and I'm not sure where to place all of the events like Prepare, Commence, and Move out, because defined movement would be all over the place.
Started implementing Move Safely little by little. It likes to crash a lot... And I'm not sure why.
Now it's just getting aggravating. I have two objects now with the exact same collision code and very similar movement schemes. One works fine when hitting backdrops, and one does not. Yet both work perfectly fine when hitting obstacles that are Active Objects.
Do I need a separate Move Safely 2 Object per player/ enemy?