September 28, 2021, 18:06:52

Author Topic: 3D model hit detection  (Read 378 times)

Offline Pfaber11

  • Hero Member
  • *****
  • Posts: 796
  • Bonjour
3D model hit detection
« 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.   
HP 15s i3 1.2 upto 3.4 ghz 128 gb ssd 16 gb ram 15.6 inch screen.

Offline Dabz

  • Sr. Member
  • ****
  • Posts: 450
  • Is it cos I is ginger?
    • dabzy.co.uk
Re: 3D model hit detection
« Reply #1 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

Intel Core i5 6400 2.7GHz, NVIDIA GeForce GTX 1070 (8GB), 16Gig DDR4 RAM, 256GB SSD, 1TB HDD, Windows 10 64bit

Offline iWasAdam

  • Hero Member
  • *****
  • Posts: 2464
Re: 3D model hit detection
« Reply #2 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 :)

Offline Pfaber11

  • Hero Member
  • *****
  • Posts: 796
  • Bonjour
Re: 3D model hit detection
« Reply #3 on: April 04, 2021, 15:21:19 »
Thanks for the advice gonna try the cube idea and go from there .
HP 15s i3 1.2 upto 3.4 ghz 128 gb ssd 16 gb ram 15.6 inch screen.

Offline Pfaber11

  • Hero Member
  • *****
  • Posts: 796
  • Bonjour
Re: 3D model hit detection
« Reply #4 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 .
HP 15s i3 1.2 upto 3.4 ghz 128 gb ssd 16 gb ram 15.6 inch screen.

Offline Dabz

  • Sr. Member
  • ****
  • Posts: 450
  • Is it cos I is ginger?
    • dabzy.co.uk
Re: 3D model hit detection
« Reply #5 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
Intel Core i5 6400 2.7GHz, NVIDIA GeForce GTX 1070 (8GB), 16Gig DDR4 RAM, 256GB SSD, 1TB HDD, Windows 10 64bit

Offline blinkok

  • Sr. Member
  • ****
  • Posts: 377
Re: 3D model hit detection
« Reply #6 on: April 04, 2021, 21:18:01 »
You might want to look into the raycast functions

Offline Dabz

  • Sr. Member
  • ****
  • Posts: 450
  • Is it cos I is ginger?
    • dabzy.co.uk
Re: 3D model hit detection
« Reply #7 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
« Last Edit: April 04, 2021, 21:25:43 by Dabz »
Intel Core i5 6400 2.7GHz, NVIDIA GeForce GTX 1070 (8GB), 16Gig DDR4 RAM, 256GB SSD, 1TB HDD, Windows 10 64bit

Offline Pfaber11

  • Hero Member
  • *****
  • Posts: 796
  • Bonjour
Re: 3D model hit detection
« Reply #8 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 .
« Last Edit: April 05, 2021, 15:28:38 by Pfaber11 »
HP 15s i3 1.2 upto 3.4 ghz 128 gb ssd 16 gb ram 15.6 inch screen.

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal