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 / Get object id of collided object

Author
Message
300happy
16
Years of Service
User Offline
Joined: 21st Feb 2008
Location: Indiana, USA
Posted: 9th May 2009 00:24
Ok, I know we can test object collision with any other objects by doing

Object Collision (A, B)

Where to test for anything else in the world, we can set B to 0.

However, I need to get the id of the object that fits B, so that I can delete it.

This is for an editor, where the cursor object used for 3d placement needs to be able to delete what it is touching if the space is filled. Obveously, the objects are created in whatever order the user places them, so I need to test if something is actually overlapping the current space in order to tell if the space is filled or not.

Precision isn't needed at all, so I'm not using sparky's or a plugin for this as that would be overkill. The objects in the level start at object id 1000, and go to infinity as they are placed. (in the final version, they'll probably be a point system to limit the number of blocks placed, but for now I just want it working.) In theory, the objects XYZ also will be equal to the space's XYZ, but I'm trying to avoid this so that the game can move things off the grid and still edit them. (Example, I run the level, and an enemy moves in between two spaces. I can still delete him by selecting either space so the cursor overlaps him, and hitting delete, even though he isn't "on the grid" anymore.)

Any ideas or suggestions? I'm just not sure where to start for this part of the editor.
BMacZero
18
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ NA / USA
Posted: 9th May 2009 06:18
OBJECT COLLISION will return the ID of the object collided with if you use 0 for B.

By the way, Sparky's is never overkill - it is not only far more accurate, but far faster than DBP's commands.



300happy
16
Years of Service
User Offline
Joined: 21st Feb 2008
Location: Indiana, USA
Posted: 9th May 2009 23:25
Sparky's is overkill if I don't even fully understand DBPro's collision, much less the raytracing stuff Sparky uses, and I'm getting 3000 fps so I don't see the point of speeding things up yet, as already it's way too fast without some serious math position division. I just need a "is this over this" calculation at this point, not some fancy 3d maths for finding the perfect distance between two points. :p

Plus, I don't know what the hell Sparky's maths do anyway. I'm still learning how to do stuff in 3d, without the use of a 2d pixel sprite engine to test for collisions with.

In short, I have no idea what I am doing, so handing me an awsome thing like Sparky's would just make me totally give up in frustration at this stage once any sort of error or syntax problem came up.

Not to mention I've installed sparky's and the help file doesn't mention any of the new commands, leaving me pretty clueless as to how I am supposed to find the documentation. I'm HORRIBLE at remembering commands since I'm trying to study PHP and DBPro is just my "fun time" project, so most of my programming time is spent looking up the syntex of things like IF statements to make sure I don't type them wrong, so even if I followed an online tutorial I'd just forget how to do the collisions the next day without documentation.
Cagedrei
15
Years of Service
User Offline
Joined: 18th Mar 2009
Location:
Posted: 13th May 2009 21:52
If you spend a lot of time hunting through the DBP help files, this may make things easier for you. It alphabetizes the main help index.

http://forum.thegamecreators.com/?m=forum_view&t=144978&b=6
the destroyer
15
Years of Service
User Offline
Joined: 24th Dec 2008
Location:
Posted: 15th May 2009 08:30 Edited at: 15th May 2009 08:48
it's very simple brother all you have to do is to setup the player's collision like so


1.the object number is the number of the object you want to setup
2.the groupnumber is the group you want the include the object in, if set to 0 then the object is not in any group.
3.collisiontype is the type of collision you want to make, 0 for polygon collision that checks all the polygons in the object, 1 for box collision that makes a box around the object, 2 for sphere collision that makes a sphere around the object.


allright now we have to save the oldposition of the object and the newone

do it in your main loop



allright now we saved the posiion of the player, nw we have to check for collision.

we use this command in the main loop
sc_sphereslidegroup(groupnumber,oldx,oldy,oldz,x,y,z,radius,exclude object)

groupnumber is the group that we want to check collision for, oldx, oldy, oldz, x, y and z is the variables that we declared above and radius is the size of the player /2, so if the player's size is 40 then the radius will be 20
exclude object will exclude an object from the collision checking if set to 1, else it must be set to 0

so here is an example showing how to use this command, use it in the mnain loop



and if you don't undertand something then just email me at mahmoud_kossir@hotmail.com
300happy
16
Years of Service
User Offline
Joined: 21st Feb 2008
Location: Indiana, USA
Posted: 15th May 2009 17:58
Umm...thanks?

But sc isn't a valid command since I don't have Sparky's Collision, and those commands don't exist in the default DBPro toolset.

As I stated a couple posts back, I DON'T want to use Sparky's because it's way overkill for this type of thing, plus I haven't mastered the basic DB collisions, so I really don't want to give myself the headache of understanding some plugin's commands as well when I haven't understood the basics. I don't need perfect player collisions, I just need to get the id of the object overlapped, which as someone posted, is done by testing for id 0.

Login to post a reply

Server time is: 2024-09-28 06:24:17
Your offset time is: 2024-09-28 06:24:17