Is there a way to calculate the closest point from a character to an area?

Started by TheManInBoots, Wed 28/08/2019 18:12:29

Previous topic - Next topic

Khris

No need to apologize; I was actually hesitant to post that because I thought I might not have the full picture.
It's just that after doing this for so long, I always see XY problems everywhere :-D :P

Cassiebsg

Also, it wasn't meant like "go fix your sprites", but more like "next time, you know there are other options so you don't get into a coding problem."  ;)
There are those who believe that life here began out there...

Crimson Wizard

Have anyone tried LockViewAligned and LockViewOffset as an alternative to manually add empty regions to sprites?

E.g. LockViewAligned:

QuoteThe main purpose of this command is that it can align the new frame to the previous one. This is particularly useful if you want to go from the character's normal walking view to a specific animation - since characters have the central point as their 'axis', if you have a wider animation then it can be difficult to stop yourself getting a jumping effect when the animation starts.

Cassiebsg

I didn't even knew that existed, much less use it.  8-0
But maybe that's exactly what the author of this thread needs?  :)
There are those who believe that life here began out there...

Khris

It depends on the sprites I guess; if they are not hugely off-center, centering the sprites is preferable. But if the animation required huge transparent areas on one side to keep the feet centered, using an aligned view seems the better solution.

TheManInBoots

Quote from: Crimson Wizard on Fri 30/08/2019 16:21:14
Have anyone tried LockViewAligned and LockViewOffset as an alternative to manually add empty regions to sprites?

E.g. LockViewAligned:

QuoteThe main purpose of this command is that it can align the new frame to the previous one. This is particularly useful if you want to go from the character's normal walking view to a specific animation - since characters have the central point as their 'axis', if you have a wider animation then it can be difficult to stop yourself getting a jumping effect when the animation starts.

Doesn't really help me in my case.
It simplifies placing the character in the right place and can make a cleaner script, but the character still ends up outside the walkable area this way.

TheManInBoots

Quote from: Khris on Fri 30/08/2019 00:51:35
No need to apologize; I was actually hesitant to post that because I thought I might not have the full picture.
It's just that after doing this for so long, I always see XY problems everywhere :-D :P

Just don't be a dick when sharing your ideas, like when you said we were just " messing around".
That's one of the main forum rules to give constructive feedback.
You don't know everything and even with the right sprite orientation I still need the dummies and function.

Khris

I wasn't my intention to label what you are doing as "messing around".
What I meant was that knowing about all possibilities and picking the optimal solution is better than using a messy one, working or not.

Of course I don't know everything; sometimes other people suggest solutions I wasn't even aware of existed.
And sometimes other people suggest solutions I consider messy, and since this isn't the critics lounge but the technical forum, I'll chime in in such a case.

TheManInBoots

Okay, no worries then.

For most view changes it is helpful to change the sprites' orientation in my game and use all the previous tips and ideas, but I still have one animation left for which I haven't found a better solution than actually using the dummy and the "PlaceOnWalkableArea" function.
That's when the character is being catapulted by a big metal spring. He is being catapulted in "3d" space so to speak, diagonally to the back of the room, so he's walking against the spring and then being pushed by the spring forwards and flying away, and becoming smaller while flying away obviously. So when the character detaches from the spring, the solution with the "PlaceOnWalkableArea" function is the best one in my opinion for two reasons:

1) Editing the sprites messes up the scaling: If I aligned all the sprites to have the same y-baseline (the sprites with the metal spring being bent by the character, and the sprites with character detached from the metal spring by himself), it would completely mess up the scaling of my character, because the baseline of the spring is significantly bigger (and closer to the screen) than the character himself, so the character's scaling has to be smaller than the scaling of the metal spring. Fixing that through ManualScaling would be extremely messy because then I cannot use the intuitive scaling of the walkable areas anymore in the follow up and would have to create a complete manual Scaling system, for every single Walkable area individually, and that would be really messy.
And just in general having too big of a z-offset for my character might affect the scaling too much.

2) When you place the metal spring somewhere, even when the baseline of the metal spring is inside the walkable area, the "catapulting" end of the spring might still be outside the walkable area, because the spring is lying diagonally towards the back of the screen in space. So when you are catapulting yourself, you will end up outside the walkable area. Now when that happens and the spring is lying in front of the truck for example with the end outside of the walkable area, I will move the character first into the walkable area before playing the view that shows the character "crashing" against the truck. Maybe you could also move the character while animating the crash view or after it. Because if you don't move the character, then the character is floating in space in front of the truck after the crash animation, and is standing outside the walkable area.

I don't know if there's a better way to do this.

SMF spam blocked by CleanTalk