Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Sliding collision detection problems

Author
Message
Game_Code_here
4
Years of Service
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 25th May 2023 17:39 Edited at: 25th May 2023 18:01
So I get perfect sliding collision for my player object, but.

My enemies that are free roaming do not get collision at all with each other even if I put them in there own sliding code.

I was thinking perhaps it is because there loaded into a array from a type?

Or perhaps it is there size being scaled permanently?

When I give them sliding collision with the world they get perfect sliding collision.

But I do not know how to give them there own collision in-between each other as there loaded as a array and the system is looking at them as the same so how can the same objects have collision with its self. I could be wrong and correct me if I am but this is what I see in my mind.

When there are two or more attacking the player they slide into each other pos and sometimes there is three or four enemies all in the same pos.


Edit<

Here is my whole function that will not detect collision for my enemies with each other.


29 games
18
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 18th Jun 2023 16:57
I believe the problem is here:



All the parameters of the sphere cast belong to the same npc, FreeEnemy[x]. The npc is checking for collision with itself. What you need to do is check for collision against all the other npcs.

The sphere cast code needs to look more like this (Note that the object that the sphere cast checks changed to "y")



The current code is not particularly efficient as it will do each check twice. For instance if there a 3 npcs, with FreeEnemy.length = 2
- On the first loop of x it'll check x=0 againt y=0, y=1 and y=2.
- On the second loop of x it'll check x= 1 against y=0, y=1 and y=2.
- On the third loop of x it'll check x= 2 against y=0, y=1 and y=2.

It does each check twice and also checks each npc against itself. So it's more efficient to do:



So,
- On the first loop of x it'll check x=0 against y=1, y=2
- On the second loop of x it'll check x= 1 against y=2
- On the third loop of x it'll check x= 2 but now y=3 which is higher than the maximum value of FreeEnemy.length so this will end the loop.

Hope this makes sense.
Game_Code_here
4
Years of Service
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 12th Jul 2023 06:34
29 games

Thank you for the look and help.

I have not been coding for awhile and took a break so i will test this soon and let you know.

What you said is true and Sounds right so i am sure it will work.

And When I was writing this code I was trying to wrap my head around array groups and could not figure how to include each one. What you showed looks more sound.



Login to post a reply

Server time is: 2024-11-21 12:25:42
Your offset time is: 2024-11-21 12:25:42