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 / Problems with Collisions/Gravity in game

Author
Message
Sazex
16
Years of Service
User Offline
Joined: 29th Aug 2008
Location:
Posted: 6th Dec 2011 09:49 Edited at: 6th Dec 2011 09:53
Now, before anyone asks me to use the search button, I just wanted to say I have... numerous times. I have tried sparkys collision, but most of the tutorials I find make a matrix,whereas I load a mesh, and I don't get how to connect those two objects (the main object I control and the level) into colliding into each other.

Also, I was just wondering if Sparky's Collision comes with gravity codes as well.

(btw, I have looked at the tutorials in Sparky's Collision, with no luck.)

Here is ALL of my code
(I know its not the best)


So if anyone can help me that would be very much appreciated

If anyone cares this is how the game looks:
http://i250.photobucket.com/albums/gg258/sazex/Untitled-11.png

sazex

Attachments

Login to view attachments
chafari
Valued Member
18
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 6th Dec 2011 11:56 Edited at: 6th Dec 2011 11:57
Hi Sazex. Sparky's comes with several examples, and one of them is a first person/3d person, and it has gravity and you can easily put your map in it. Of course, you will have to scale you level to fit the size collision. Sparky is free, download it and if you have any problem we can help you.

Cheers.

I'm not a grumpy grandpa
MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 6th Dec 2011 21:20
Sort of on topic... how complete is sparkys? and how does it compare to Dark Physics?

Sazex
16
Years of Service
User Offline
Joined: 29th Aug 2008
Location:
Posted: 7th Dec 2011 06:01
@ chafari, ok so I tried what you said, and took another spin on the examples that came with SparkysCollision, but unfortunately did not help me at all

Though I did look online for some more tutorials and thought I'd give one another try, and it yielded some results, though, not what I expected or want.

Whenever I try to move the object, from another position than its starting position, it just falls through the ground, or flies straight up.

here is my code if you know what I am doing wrong:



@MrValentine, well I do not have DARKphysics, so I can not say, but if you want, you can try out Sparky'sCollision for yourself, here is the link:
http://forum.thegamecreators.com/?m=forum_view&t=74762&b=5

sazex
chafari
Valued Member
18
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 7th Dec 2011 11:36
Hi Sazex. I test your code, and you don`t have gravity. Test you level with this code. Example complete attached



Cheers.

I'm not a grumpy grandpa

Attachments

Login to view attachments
Bulsatar
13
Years of Service
User Offline
Joined: 19th Apr 2011
Location:
Posted: 7th Dec 2011 14:43
To go along with chafari's code...
It would be a good idea to spend a day or so and get comfortable with creating your own UDTs (user defined types). When you use these, you can compartmentalize values that are specific to each thing and reduce the amount of code that you use. For something specific and quick, they are not that important...but when you have hundreds of different types of objects (players, enemies, bullets, health pickups, world clutter, etc.), setting each to a udt is almost essential to keep things organized.
Sazex
16
Years of Service
User Offline
Joined: 29th Aug 2008
Location:
Posted: 8th Dec 2011 07:47 Edited at: 8th Dec 2011 09:04
@chafari wow thanks! It did the trick, but for some reason the character is still floating over the land, though he is colliding with the buildings so many thanks for that... but if you know why he is floating over the map that would be awesome
here is a pic:
http://i250.photobucket.com/albums/gg258/sazex/Untitled-12.png

heres the updated code:



@Bulsatar Thanks, I'll have to look into UDTs, they seem important

sazex
chafari
Valued Member
18
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 8th Dec 2011 12:31
Quote: "the character is still floating over the land, though he is colliding with the buildings "


Perhaps you need to scale your level a bit biger, or your character a little bit smaller. Can you send me your level and Character to test

I'm not a grumpy grandpa
TheComet
17
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 8th Dec 2011 13:43
No that's not the problem. Your character's center point is located at it's feet, and that's also the point where you perform a sphere cast. This means the character will be offset from the ground by the radius of the sphere cast. Untested, but this should fix it:



TheComet

Sazex
16
Years of Service
User Offline
Joined: 29th Aug 2008
Location:
Posted: 9th Dec 2011 01:32
Thank you so much Comet, it did the trick! I now have my character correctly colliding with the floor and the buildings!

sazex
theSPACEmafia
13
Years of Service
User Offline
Joined: 5th Jan 2011
Location: somewherez majikalz
Posted: 19th Dec 2011 16:00
on a similar note i am making a maze game where the camera is above everything and the character keeps going through the walls and i cant make it stop

tsm
theSPACEmafia
13
Years of Service
User Offline
Joined: 5th Jan 2011
Location: somewherez majikalz
Posted: 19th Dec 2011 16:21
also im just using dark basic pro with the physics provided because im using school provided software

tsm
nonZero
13
Years of Service
User Offline
Joined: 10th Jul 2011
Location: Dark Empire HQ, Otherworld, Silent Hill
Posted: 19th Dec 2011 18:32
@theSPACEmafia:
Quote: "on a similar note i am making a maze game where the camera is above everything and the character keeps going through the walls and i cant make it stop"


The SET CAMERA TO FOLLOW command has a special flag to have this situation automatically handled.

From DBPro help:

Quote: "SET CAMERA TO FOLLOW

This command automatically controls the camera to provide a tracking system. By providing the 3D world coordinate of the entity you wish to
track, and some camera data, your camera will automatically update its current position each time this command is called. The X, Y, Z and
Angle values provide the coordinate to track. The Distance value specifies the required distance between the coordinate and the camera. The
Height value specifies the required height of the camera in 3D space. The Smooth value specifies the level of smoothing required for the
camera, where a value of 1.0 is no smoothing and a value of 100.0 is lots of smoothing. The Collision value is a special flag that allows the
camera to detect whether it is hitting any of the static collision boxes and if set to one will automatically adjust so as not to enter these
collidable areas."


theSPACEmafia
13
Years of Service
User Offline
Joined: 5th Jan 2011
Location: somewherez majikalz
Posted: 19th Dec 2011 20:44
my maze is made of cubes and the red cube is being treated as my test cube how do i stop the controlable cube (cube 1) from colliding with the red one

also i know that it should be organized beter but ill work on that at another time

tsm
29 games
19
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 20th Dec 2011 02:15
Hi, theSPACEmafia.

Have a look at TDK's turtorials:

http://forum.thegamecreators.com/?m=forum_view&t=99497&b=10

Tutorial 10 "Dark Basic Collision Made Simple" is probably what you want.

Also, you might want to make the controlled cube a little bit smaller than the cubes used for the maze so that it's not constantly touching the walls. This could cause problems when you come to use the collision commands.
theSPACEmafia
13
Years of Service
User Offline
Joined: 5th Jan 2011
Location: somewherez majikalz
Posted: 20th Dec 2011 16:32
thanks for the referal it helped alot

tsm

Login to post a reply

Server time is: 2024-11-23 23:57:37
Your offset time is: 2024-11-23 23:57:37