I’ve been trying to solve this for over a month now (in between other things) and still have no idea what’s wrong.
I have a script attached to an enemy character that tells it to locate the nearest wall, climb up said wall, then fly at the player character after climbing to the top and getting a direct line of sight with the player. Simple, right?
Well, my code’s mostly working, but about 3 of every 10 enemies with this script on it find themselves stuck inside the wall. I’ve tried just about every way I can to correct their positions to no avail.
Could someone tell me what I’m doing wrong? Here’s the relevant part of the script.
please post a video of this happening, it’s worth 1000 words truly.
Why aren’t you using debug information to see what state the character is in when it’s stuck? That should be enough to solve already.
What have you tried already? Debugging questions I can understand, sometimes you just can’t see it after becoming intimate with it, but I think you want to provide things you’ve tried and as much info as possible to get better answers.
I gave it a glance over, my first thought goes to how you are handling character’s height. You are asking the script to check the pivot against bounds max y. If “Speed” is a function of deltaTime, it may not be in effect clearing the wall in reality (bounds are still at odds with each other) even tho your pivot has cleared the boundaries. You can test by making speed very fast and see if it ever gets stuck. (and i mean VERY fast, tho this isn’t 100% guaranteed). You should at least check the min bounds of the player’s y, or at the very least check for collision against the wall, while a collision, keep boosting the player higher.
I also think using the code in this way makes for problems. The far easier way is, once you reach a wall, make SURE it gets over the wall by knowing ahead of time the character height -vs- the wall height. Then instead of calculating the position each time, you send in preprocessed information that will make sure it gets cleared. Most AAA game engines make sure the size of characters are accounted for ahead of time and use a smart object system that allows you specify where a character can start to climb a wall (or whatever) and where they will finish visually in the editor.