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 / I want to create game where 2D is mixed with 3D

Author
Message
Laszlo
18
Years of Service
User Offline
Joined: 11th Dec 2005
Location:
Posted: 8th May 2006 20:29
I'm a beginner and I have a problem with collisions. My main character is a sprite and I placed him in 3D world. There is a building and I want walls of this building to block main sprite. How to make it???
Help me please.
Pincho Paxton
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 9th May 2006 02:53
If the building doesn't rotate then you can use a zone which is the top/left corner xy pos to the Bottom/Right corner xy pos.

If it does rotate then maybe you could put a temporary invisible sprite there, and rotate the sprite with the building. (Not sure if you might need a dll to do that because of some collision problems with rotated sprites.)

You could use box collision, and put a box where the building is, and a box where the sprite is but they are hidden.

Laszlo
18
Years of Service
User Offline
Joined: 11th Dec 2005
Location:
Posted: 9th May 2006 15:44
The building doesn't rotate but sprite rotates.I want to create box collision but I don't know how does it work. I tried "make static collision box" on walls but nothing happenned. And I think I should make collision on my sprite too but I don't know how. Which command should I use to make collisions on main sprite and on walls? Collision on sprite should move. I use Dark Basic Pro.
Twu Kai
19
Years of Service
User Offline
Joined: 2nd Oct 2005
Location:
Posted: 9th May 2006 16:12
I think you need to use a plain, it's basically just a two-sided object, like a sprite.
This is an example:


Then, when you've got the type of collision you want, maybe make another object, like a cube, and position ot at the plain position, and set the collision to the cube!

I hope I've helped in any way.

Join The Clan! http://www.torak.info

Desteya colatiata hethayas thorian helltastha lutanithan atelthuron ilonthes!
D Ogre
21
Years of Service
User Offline
Joined: 19th Nov 2003
Location:
Posted: 10th May 2006 00:50
Collsion can be a little tricky at first for a beginner. There are many ways to handle this. It depends on how complex your scene is. This will determine your approach. Sometimes you my do it one way, but find out that you may have to rework it later.

Box collision is probably the best for this situation. This is because you are dealing with square or rectanglar objects. I usually don't rely on canned methods (DB collision handling commands) unless they are a best fit solution.

One way of doing this would be to define a set of arrays which hold the size of the objects in question relative to its position or origin. Store the current position of your sprite or object in a set of temp variables. Then make the calculation for movement, and check to see if the new position has invaded another object's boundries. If it has, make the new postion equal the old position. If it has not, then go ahead and update the actual objects position with the newly calculated variables.

I suggested using arrays because you can check multiple objects by using a loop that just changes the index number for the arrays. The index number for the array would represent the object you are checking collision with. This would be done before you finalize your new position.
Laszlo
18
Years of Service
User Offline
Joined: 11th Dec 2005
Location:
Posted: 10th May 2006 21:47
Thats what I made(I hope you see this code):


And now, a question. What should I write? "Make static collision hit" on main sprite? Another command? If you know tell me what and where should I write.
D Ogre
21
Years of Service
User Offline
Joined: 19th Nov 2003
Location:
Posted: 11th May 2006 04:22
To simplfy things a bit in your situation, I would suggest using a object plain instead of a sprite. This way you can use all of the 3D collision commands in DBPro. Otherwise you will have to create a collision table with arrays to handle your collision as I mentioned earlier. Although this can be done, but it requires more work and can complicate things a bit.

Using a plain object will require you to grab the images yourself from a pre-existing sprite sheet, and then use the images as textures. Make sure that you use the texture disable flag when loading them. This will result in a pixel perfect image. All of the animation done with the textures will have to be handled by you manually. You will also have to set the transprency on the object.

I provided a simple collision example program below. Hopefully, the program will give you some idea of how to do collision between two objects. Like I said before, collision can be done many different ways. This depends on how complex your scene is. If you are just checking for collision between a few objects and all but one is static (not moving), you could possibly use the code below to get you started. If you want to check for collision between a game player and a full 3D environment, then you would use sliding collision.

Sliding collision is basically creating collision zones in your world. These zones can be defined for walls, floors, ceilings, or what ever so that when you collide with them you can keep your character(s) from passing thru them. I believe there are some examples for this around here in the forums somewhere. A complete explaination here is beyond the present scope. Another source would be some of the 3D demos provided with DB and DBPro. If I remember correctly, they use some sort of sliding collision.

Anyways, check this example program out and see if it is useful to you. I think I have a program that I did just for kicks that used an animated plain object using image textures. If I can find it, I will post it here for you to look at later.



Hope this helps!

Login to post a reply

Server time is: 2024-11-27 19:45:57
Your offset time is: 2024-11-27 19:45:57