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.

Newcomers DBPro Corner / calculate the position inbetween two objects

Author
Message
Ignatura
7
Years of Service
User Offline
Joined: 20th Sep 2016
Location:
Posted: 29th Oct 2016 09:35
right so I've got a gun firing bullets and I want to make a bullet hole at the exact position in between bullet and the object it collides with? any suggestions???
Ortu
DBPro Master
16
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 30th Oct 2016 01:50
However you are detecting a collision, you should be able to get the coordinates of the collision. That's where you position the hole


A single player RPG featuring a branching, player driven storyline of meaningful choices and multiple endings alongside challenging active combat and intelligent AI.
Scorpyo
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: italy
Posted: 30th Oct 2016 08:06 Edited at: 30th Oct 2016 08:06
If you will be using decals here is some "schizo" code.
Doesn't really work well with curved surfaces
Cheers

Ignatura
7
Years of Service
User Offline
Joined: 20th Sep 2016
Location:
Posted: 30th Oct 2016 12:00
Ortu wrote: "However you are detecting a collision, you should be able to get the coordinates of the collision. That's where you position the hole"


I can't find anything in the index that would support this theory and Scorpyo your code doesn't work.
Ortu
DBPro Master
16
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 30th Oct 2016 18:00


Alright, let's take it one step at a time.

How are you currently detecting a collision between your bullet and an object?


A single player RPG featuring a branching, player driven storyline of meaningful choices and multiple endings alongside challenging active combat and intelligent AI.
Scorpyo
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: italy
Posted: 30th Oct 2016 23:47
My code should do what you see in this video
Not sure why it doesn't work for you

Attachments

Login to view attachments
Ignatura
7
Years of Service
User Offline
Joined: 20th Sep 2016
Location:
Posted: 1st Nov 2016 08:20
Ortu wrote: "
Alright, let's take it one step at a time.

How are you currently detecting a collision between your bullet and an object?"


the simplest way possible:



Scorpyo wrote: "Not sure why it doesn't work for you"


Try and build a simplified version without functions, my db pro application just won't run your code as it is, it kept complaining about spaces in between lines then didn't recognise the loop after your sync statement???
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 4th Nov 2016 04:04
Scorpyo's code works fine for me.

Ignatura, since you are using DBP's native collision, it will be difficult to come up with the actual X, Y and Z coordinates of the collision point. The command:
Return Float=OBJECT COLLISION CENTER X(Object Number) will only give you the center coordinate of the object you hit, so it is pretty much worthless. What I did is looked at the coordinates of the bullet once it collides with the 'robot', place the bullet hole there and hide the bullet itself. Here is a crude example:


You move around using the arrow keys. Once the 'robot' (i.e. sphere) is in the middle of the camera, click the left mouse button and it will fire a bullet at it. If it registers a hit, it will tell you and then put a bullet hole at the collision point.



So many games to code.....so little time.
Ignatura
7
Years of Service
User Offline
Joined: 20th Sep 2016
Location:
Posted: 5th Nov 2016 20:15
your code didn't really work at first or do what you where showing an example of? i'm looking for something more in depth possibly involving sin and cos ect?

Derek Darkly
12
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 7th Nov 2016 23:22
I think basically what everyone is trying to say is that you need to learn how INTERSECT OBJECT works, then you will get the exact point of your bullet hole.
After that you simply slap a PLAIN object with a bullethole texture on it.
Send your parents to noisy sprite demo hell... enter the D-Zone
smerf
19
Years of Service
User Offline
Joined: 24th Feb 2005
Location: nm usa
Posted: 31st Dec 2016 18:20 Edited at: 31st Dec 2016 18:24
x1=bullethitx
x2=playerposx
(x1+x2)/2=middlex
z1=bullethitz
z2=playerposz
(z1+z2)/2=middlez

`break a window at new x and z
do something at middlex,y,middlez,

no time to test this but seems like it should work ok take 2 numbers start x and target x say 10 and 104 add and divide to find the median 114/2= 57 ,
prolly the first thing I would try I like to keep things as simple as possible
A child's dream never dies.





Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 20th Feb 2017 21:32
Ignatura mentioned that Scorpyo's code caused complaints about lines containing spaces when he tried to run it. I had exactly the same problem a few days ago when I was testing someone's code from the forum. I have no idea what caused the issue but I have enough experience to resolve it myself but I guess Ignatura might not so bear this in mind when he reports such difficulties. The problem could be a quirk of the editor used for the code.
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 23rd Feb 2017 18:34
I suggest looking at the example supplied with Sparky's collision DLL. It uses a line intersection check, returns the collision point, and the normal at that location - which means you can rotate a plain to be flat on the surface. If you can't find it, I'm sure I can attach it for you.
The code is dark and full of errors

Login to post a reply

Server time is: 2024-04-20 06:46:16
Your offset time is: 2024-04-20 06:46:16