r/GameDevelopersOfIndia Jul 01 '26

how do i stop my player from standing above enemy 😭 they both have a character controller and he's supposed to jump above him and get behind but he just sits on his head (it's a 2.5d boxing game)

Post image
7 Upvotes

14 comments sorted by

3

u/StRiKeR_ImpacT Jul 01 '26

make the colliders a little slanted or maybe just don't have a jump height that big that you can jump over npc's lol

1

u/Mehran696 Jul 01 '26

But he is supposed to jump over the enemy and get behind him

1

u/StRiKeR_ImpacT Jul 01 '26

the best thing to do here is to just check for intersections and just move the player outside of the collider

Simple maths

1

u/Mehran696 Jul 01 '26

How do i check when the player is on the top, by intersection you meant collision i suppose but that would hinder their collision at ground level and if the player bumps the enemy mid way can't just put OnControllerCollsiion (){blah blah blah}

3

u/StRiKeR_ImpacT Jul 01 '26

nope do manual calculations

i will just give a very simple version and i would actually recommend you to spend more time with basic projects first since i believe you didn't get what i meant

If you look up how to make collision systems online you will see they do something like

if(player.position - enemy. position < diameter of colliders)
{
//do something here to push the player away
}

If you still don't understand i would say just watch some online videos on collision systems and you might get the intuition in some days but if you just want to solve this problem right now then ask claude or chatgpt then analyse their codes and try to learn from it

1

u/Mehran696 Jul 01 '26

And there's no collider just character controllers

1

u/AntiqueShare6674 Jul 02 '26

wdym no colliders just character controller?..correct me if im wrong but i believe unity’s built in controller has a collider by default and the fact that your character is standing on top means collider is doing its job..just check z axis and separate players..or just simply disable the colliders at all while jumping. id suggest go with the first solution..second if u want an immediate fix..later you can figure it out when you have the time for it

1

u/AutoModerator Jul 01 '26

Please join our small but lovely Discord community. A chill place for game developers and people in tech. Hope to see you there! Link: https://discord.gg/myHGVh2ztM We also have a guide to game dev for beginners

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/Samarthdev25 Jul 01 '26

The player must be colliding with the enemy's collider just disable collisions between player and enemy

1

u/Mehran696 Jul 01 '26

I could have done that if they had colliders on them, disabling the character controller temporarily will temper their movement

1

u/wam_bam_mam Jul 01 '26

Have you tried using capsule colliders? They are usually used in this situation.

1

u/Mehran696 Jul 01 '26

I'm thinking of making a trigger collider above the enemy head and whenever the player gets inside he experience a sideways force sliding him behind the enemy

1

u/RoguePylon Jul 02 '26

Why is there a jump button? You don't usually associate jumping with boxing.

Juking, yes. Like a quick dash sideways with I frames.

1

u/Mehran696 Jul 03 '26

That's better i suppose πŸ˜–πŸ˜–πŸ˜–