SyntaxBomb - Indie Coders

Languages & Coding => AppGameKit ( AGK ) => Topic started by: Pfaber11 on April 04, 2021, 13:32:30

Title: 3D model hit detection
Post by: Pfaber11 on April 04, 2021, 13:32:30
Hi been using 3D wings to make my models . I'm having a problem in that when I shoot one of the enemy I have to hit it straight in the middle to register a hit . I want to be able to hit it anywhere to register a hit . Any help would be good . I have had it working the way it should but for some reason cannot replicate it.   
Title: Re: 3D model hit detection
Post by: Dabz on April 04, 2021, 14:10:57
Try replacing your mesh with just a standard cube and see what happens, and/or, use your mesh with the collision example code{s} in the command help.

If you get the same result with the standard cube, your code is wrong, and, well, use the example code because it's how you do it... If your mesh does the same with the example code, then there is something wrong with your mesh.

Prod and poke, thats all you can do, without anything to look at or try, its guess work.

Dabz

Title: Re: 3D model hit detection
Post by: iWasAdam on April 04, 2021, 14:54:28
the key is your hit detection is separate from the 3d display. you can use simple basic hit detection on rects and then transfer the result to your 3d :)
Title: Re: 3D model hit detection
Post by: Pfaber11 on April 04, 2021, 15:21:19
Thanks for the advice gonna try the cube idea and go from there .
Title: Re: 3D model hit detection
Post by: Pfaber11 on April 04, 2021, 18:38:35
HI sorted it and it was a case of my projectiles moving too fast . Slowed them down to 60 units a frame and all better . I was going at 600 or even 1000 units per cycle and although it was like a machine gun it would only register a hit if hit dead center. Used the cube idea and it was doing the same . Anyway thanks for the suggestions . Have a nice evening .
Title: Re: 3D model hit detection
Post by: Dabz on April 04, 2021, 20:59:24
Ah good... I thought it might be code, but I'm on the understanding AGK doesn't acknowledge backfaces when it comes to collisions, not that I'm a expert on 3D stuff, which I'm definitely not, but, you never know, something could of gone squiffy on the export, so worth the check.

Dabz
Title: Re: 3D model hit detection
Post by: blinkok on April 04, 2021, 21:18:01
You might want to look into the raycast functions
Title: Re: 3D model hit detection
Post by: Dabz on April 04, 2021, 21:23:11
Quote
You might want to look into the raycast functions

Thats what I was presuming he was using, but depending on how the functions are used, there is still the possibility a certain sized ray check can go through an object without colliding, based on the velocity and the XYZ's given.

Dabz
Title: Re: 3D model hit detection
Post by: Pfaber11 on April 05, 2021, 09:34:20
Yes am using the raycast method . Finished my game off in studio which I rate quite highly . Thanks for the help and suggestions . The Raycast stuff used to scare me but not anymore . Not nearly as bad as it sounds once you get into it and have a play . Taken down a few of my earlier games off the internet as were really rubbish but which I thought were ok at the time .  Enjoy your day.
Forgot to mention I am now using my projectile speed at 120 units per cycle and it works fine at this speed and is just right .