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.

DarkBASIC Discussion / Collision Help

Author
Message
Flamertor
8
Years of Service
User Offline
Joined: 12th Oct 2011
Location:
Posted: 21st Jan 2012 17:49
I have done collision before but for some reason I can't get this to work for some reason. I copyed and altered my collsion from my last one but it won't work in this one. Hope you can help. Thxs in advance.

Latch
14
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 24th Jan 2012 20:44
Hello,

what do you mean by:

Quote: "for some reason I can't get this to work for some reason"

What doesn't work? What is happening?

In this code:



When you scale an object, sometimes the collision area doesn't change with the scale. Try turning off the collision after sacling it, then turn the collision back on.



With these two objects:

Load object "lvl1MapWall.x",1
Load object "lvl1Map.x",2 : set object collision on 2

Are they just cubes? Is the player "inside" of them or are they complex objects? The reason I ask is you have their collision set to boxes which just means a collision bounding box equal to the size of the object is placed around it. If it is meant to be an interior or a complex level, your collision may not behave as you hope. For these objects you may try SET OBJECT COLLISION TO POLYGONS.

Also, in this code:



Your setting collision for object 23 twice. I think one of them is meant to be object 22.

In this code:



You are limiting the position (xtest and ztest) to values between 0 and 10000, yet you have your camera positioning set over 5,000,000 and you have your camera range set to 500,000 . So there may be a lot of issues other than just the collision. The visuals may not be what you are expecting.

As a rule of thumb, I would suggest trying to keep the camera range well below 100,000 even below 50,000 actually as some weird things can happen visually with object placement at far distances. I would also try and keep the scale of objects down and try and load the objects in at the size you need them to be relative to the world. Sometimes you have to scale in game, but I personally feel it's better to avoid it and have you world set up to it's proper size ahead of time.

I like to use a scale along these lines:

2 or 3 3D units = 1 foot
5 to 10 3d units = 1 meter

You don't have to follow suit, but I've found that a small scale in DBC usually results in fewer visibile artifacts.

Enjoy your day.
Flamertor
8
Years of Service
User Offline
Joined: 12th Oct 2011
Location:
Posted: 24th Jan 2012 22:14 Edited at: 25th Jan 2012 18:59
thxs for the reply, and I have took a picture of it, I hope it helps you understand what i ment also im trying to make it so if you collide with the walls you don't go through

Attachments

Login to view attachments
29 games
14
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 25th Jan 2012 21:41
@Flamertor

This is from the DBC examples, which you may find useful:



TDKs tutorials also has a good section on using the inbuilt collision functions.
Flamertor
8
Years of Service
User Offline
Joined: 12th Oct 2011
Location:
Posted: 29th Jan 2012 19:55
thxs it helps alot I started making a new game aswell, take a look

Attachments

Login to view attachments

Login to post a reply

Server time is: 2020-08-15 12:00:37
Your offset time is: 2020-08-15 12:00:37