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 Professional Discussion / Sliding Collision Function/Commented Example - Sparky's Collision dll (V2)

Author
Message
sadsack
19
Years of Service
User Offline
Joined: 27th Nov 2003
Location: here
Posted: 19th Mar 2007 01:51
No, I understand it. I can make it work right like I want it too.
BUT!!!!! Like I said the tank is flying 20 feet in the air. The
radius have to be 80 for the gun not to go into the wall. seeing the tank and the cannon is about 3 times longer that it's hight, so the tank is flying off the ground....... But I fixed that. I remade my maze and did not put a floor in it. then I made a plain and moved it up to the hight of the tanks. that works fine. I not sure how you can call that box collision when you are using a radius for collision. but I am just a nobody What do I know.
Thanks every one for you help, I understand Sparky coll. much better now. It would be nice if DBP collision worked.
thanks again
renny
RUCCUS
18
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 19th Mar 2007 04:07
...

Its not box collision. When you set up an object for box collision, it uses bounding box collision. Originally the map was set to polygonal, which is correct. Setting a map to box collision makes it so players cant enter the map, they instead are restricted to the outer limits of the map, as if an invisible box was drawn around the map.

Theres a reason eliptical collision is the most common used, because it can be stretched to fit objects that arent a "cube"-like shape. Your tank for example, is longer in the x and z axis than it is in the y axis. When a sphere is put around this, obviously it wont work. An ellipse would be ideal.

Eliptical collision is a little different in sparky's dll, it requires you to constantly change the radius used for collision based on what direction the user is moving in. A quick workaround is to handle movement, handle collision, move the player object down whatever amount of units it takes to get them back on the ground, sync the screen, move them back up, and repeat.

sadsack
19
Years of Service
User Offline
Joined: 27th Nov 2003
Location: here
Posted: 19th Mar 2007 20:29 Edited at: 19th Mar 2007 20:30
Thank you, to bad they don't say something like that, see photo:
I got it working good not Thanks every one for your help.
renny

Attachments

Login to view attachments
RUCCUS
18
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 19th Mar 2007 21:22
Renny, they say exactly the right thing, you're just thinking about it wrong. You're setting up the map object, NOT the player object. If you use box collision to set up a map, the map will have a huge collidable box stretched around it. I say again; you are setting up the MAP, not the PLAYER. If you were setting up the player object, this would make sense, but you're not, and setting up the player object wont accomplish anything in this case.

sadsack
19
Years of Service
User Offline
Joined: 27th Nov 2003
Location: here
Posted: 21st Mar 2007 01:38
Thanks I got it
renny
Maflash
18
Years of Service
User Offline
Joined: 10th Aug 2004
Location: In my moon base
Posted: 26th Mar 2007 02:06
So how what do you think of using two spheres to check for collision in a long object? Would it not be the same as using four to check what a car's wheels are touching?

I wish I knew what I were doing!
MartinS
17
Years of Service
User Offline
Joined: 15th Dec 2005
Location: Rochester, NY
Posted: 5th Apr 2007 17:19
Hi,

I've got a question for your bouncing code: When I make the paddles on the left/right shorter. And I make them move up/down (Pong style), The ball acts as if the original position (of the paddle) is where it should collide, and therefore only collides there, and not at it's current position. Any idea why that happens?

Thanks!
Martin

RUCCUS
18
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 5th Apr 2007 18:59
Are you updating the paddle positions with SC_updateObject?

MartinS
17
Years of Service
User Offline
Joined: 15th Dec 2005
Location: Rochester, NY
Posted: 5th Apr 2007 19:08
@RUCCUS:
Thanks for the quick reply! And no, I wasn't. Again, thanks!

G2L

dononeton
18
Years of Service
User Offline
Joined: 12th Jun 2004
Location: Tusaloosa, AL : USA
Posted: 16th Apr 2007 00:25 Edited at: 16th Apr 2007 00:26
Hi guys just made RUCCUS sliding function into a dll. Try this out. Install the plugin, help, keyword files first then try code below


AMD Athlon 64 x2 Dual Core Processor 3800+,MMX 3DNOW (2CPUs)
1024 MB RAM
GeForce 7300 GT 512 MB

Attachments

Login to view attachments
RUCCUS
18
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 16th Apr 2007 02:12
Zhent
16
Years of Service
User Offline
Joined: 26th Jan 2007
Location: Cleveland
Posted: 30th Apr 2007 19:43
I've got a question for you. I'm making a world with a character walking around in it. This works beautifully whenever the character has to move uphill - however, it does not keep the character against the ground when he is moving downhill. Any suggestions to keeping him against the ground?

--
Zhent, coding newbie
RUCCUS
18
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 30th Apr 2007 21:44
Zhent
16
Years of Service
User Offline
Joined: 26th Jan 2007
Location: Cleveland
Posted: 30th Apr 2007 21:52 Edited at: 30th Apr 2007 22:00
Is there a command for that with this plugin? Or something else in DBPro that has that command? I'm rather new at this, but i havent been able to find a gravity function. I'm also not quite sure how to look most effectively.

I've tried simply adding a negative movement to the players character, but I've found that in order to keep the player on the ground, it slides the player down the inclines unless they are moving. If I reduce the amount that I move him down, then the player can walk off into the air if they move down an incline.

--
Zhent, coding newbie
RUCCUS
18
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 1st May 2007 00:41
Theres no pre-set gravity function, you program gravity yourself. Do a search for the usual gravity methods on the forums, but essentially;

- Move the user down by a certain amount
- Apply sliding collision
- If the user is colliding with the map and they're moving forward/backward, dont apply gravity.

This way if the user walks up an incline gravity doesnt effect them, and if a user walks off say a cliff, gravity will only effect them if they're completely "airborn".

Eiji88
16
Years of Service
User Offline
Joined: 16th Jan 2007
Location:
Posted: 17th May 2007 01:08
Hi sorry to barge in on the post, but can I have some help with a Sparky.dll collision problem I have?
RUCCUS
18
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 17th May 2007 01:33
Why wouldnt you just ask the question...instead of asking if you could ask the question?

..Ask away.

MikeB
15
Years of Service
User Offline
Joined: 5th Apr 2007
Location: My Computer, Shropshire, England
Posted: 21st May 2007 11:53
Hey Ruccus, I'm a complete DBP new guy .
I have, however, edited a car code so that it's a lot more realistic.
I was wondering how easy it would be to add collision to that car code, using sparky's dll.:



Thanks,

E.D.

P.S. I'm only using the trial, I'm kind of trying to find out in advance, before I buy it .

RUCCUS
18
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 21st May 2007 17:04
Car collisions are a lot different than player collisions. For one thing, cars dont slide along surfaces when they impact most of the time, because they're going so fast. Instead you'd expect them to bounce off in a different direction, possibly even flipping. Almost any game that has any vehicle in it nowadays, uses a properly written physics engine that can simulate torques, forces, etc, to get the right collision going.

So first off Id recommend using Newton for the physics / collision as it handles it all for you, except theres a big learning curve. You could go for Dark Physics, but it's not polished off yet, and isnt free like Newton.

If you're dedicated to sticking with Sparky's though, for basic car collision physics:

- When a collision occurs, first apply sliding collision to get the car out of the collision and into a reasonable place, then apply bouncing collision so the car bounces off the wall, by using sparky's bouncing collision commands. (For more help on collision go to the sticky at the top of the Newcommers Corner named "Usefull threads" or something like that, and click on the "Massive Collision Resource" link). Now your car will bounce off as well, the last thing you'll want to do is slow the car down by whatever fraction you deem necessary (half the speed, for example).

Bouncing collision will give you problems however, because if you impact a wall perfectly straight, you'll bounce back in the opposite direction, which isnt very realistic.

Instead of bouncing, you might try pointing the car to it's newly returned sliding collision position, and then positioning it there as well. That way if the car hits a wall head on, it'll come to a dead stop, if it hits it at an angle, it'll jolt a bit to one side or the other.

MikeB
15
Years of Service
User Offline
Joined: 5th Apr 2007
Location: My Computer, Shropshire, England
Posted: 21st May 2007 17:19
Ok , I think I'll wait till I feel ready to learn Newton before I finish off the game .

But I like the way the car controls at the moment.

E.D.

FERSIS
16
Years of Service
User Offline
Joined: 17th May 2006
Location:
Posted: 18th Jun 2007 02:38 Edited at: 18th Jun 2007 02:40
RUCCUS , thanks for all your work and help.
Really , thanks.
Cheers
FERSIS
16
Years of Service
User Offline
Joined: 17th May 2006
Location:
Posted: 7th Jul 2007 23:53
Hey its there a way to offset the SlidingCollision ??
i mean, putting something like SlidingCollision(X1#,Y1#-30,Z1#,X2#,Y2#-30,Z2#,Radius#,Dyn,Group)

because ive tried something like the above example .and dont work
My problem is: that my character feet are inside of the floor
and if i put a bigger radius , then it would be too big to pass on the 'doors'.
I hope that you can understand.
cheers
RUCCUS
18
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 8th Jul 2007 02:22
Instead of offsetting the collision, offset your player. Basically, handle player movement, then call the collision function, then move the player object up by whatever amount is required to get his feet on the ground, sync the screen, then move him back down at the beginning of the loop.

Either that, or try going into the function, and where it positions the user, add 30 to the y value.


FERSIS
16
Years of Service
User Offline
Joined: 17th May 2006
Location:
Posted: 8th Jul 2007 04:44
thanks , ive tried that already
And found that the problem is the 'gravity' that im applying so...
I have to think another way to do the gravity stuff
thanks
RUCCUS
18
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 8th Jul 2007 07:04
Make sure you apply gravity, and any other things that will effect the user's position, before you get the new xyz positions for the collision command, and also before you call the collision command.


Kyle Katarn
15
Years of Service
User Offline
Joined: 7th Jun 2007
Location: Central Coast, Australia
Posted: 8th Jul 2007 07:38 Edited at: 8th Jul 2007 07:43
RUCCUS, first off, thank you so much. Your tutorials have helped me heaps. I'm making a (wait for it) FPS lol, using your tuts and sparky's collision dll... you're probably going "Well, duh!" right now so I'll get to the point.

A gravity question. Basically I've implemented a gravity system from another user, but when I try to go up a ramp onto a platform, the gravity will bypass the collision checking. Im wondering if there's a way to differ a natural incline and a mouse look incline and stop it from happening.



Attached is the media file.

Edit Thanks in advance.

Attachments

Login to view attachments
RUCCUS
18
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 8th Jul 2007 16:56 Edited at: 8th Jul 2007 16:58
Most games today have actual physics engines that handle everything, collision, gravity, movement, everything that involves some sort of movement or rotation based on forces. Because of that, you can set the friction of certain surfaces, and so usually ramps and such have a good enough friction setting that the user wont slide down the ramp when gravity is applied.

Without a physics engine, a common trick is to check if the user is close to or on the ground (send an intersection check from the user's feet, to a point somewhere close below to their feet, maybe their y position minus 0.1. If an intersection is detected, it's safe to say they're probably on the ground. If you know they're on the ground, you can stop applying gravity.

Another option is to use separate maps. This can be better in a way. If you have a separate, invisible map with plains positioned / oriented wherever you have ramps, then in-game you can check if the user is colliding with this invisible map, and if so stop applying gravity or possibly even invert the gravity, causing them to move up (allowing you to add ladders).


There are some problems I can see in your code.

1. You're basically handling collision twice. You move the player, check for collision, then apply gravity and check for collision. This can be combined into 1 collision check, by storing the user's oldxyz, allowing the user to move, applying gravity, storing the user's new xyz, and calling the collision function.

2. From the looks of things (I may be missing something, I didnt look at the code too indepth), your gravity is moving you down by a constant rate. Thats not very realistic. There is a relatively simple way to get realistic gravity going, and have it work with your jumping routine to give you realistic jumping. (By realistic I mean, slowing down as you ascend, speeding up as you descend).

The variables you'll need are gravityspeed#, gravityrate#, jumpspeed#. I usually define these in a nested type, so I can access them by going physics.gravity.speed#, physics.gravity.rate#, physics.jump.speed#. If you dont understand types I recommend you look them up, they're amazingly useful for organizing variables in a sensible manner, and a must-have if you'll be doing extensive programming with arrays.

The steps:

- Check if the user is on the ground
- If false, increase physics.gravity.speed# by physics.gravity.rate#
- If true, reset physics.gravity.speed# to 0
- Move the user's object down by physics.gravity.speed#

- Check if the user wants to jump, and isnt already doing so.
- If true, set physics.gravity.speed#, to physics.jump.speed#. Assuming physics.jump.speed# is a negative value, you're player will move up at whatever jump speed you set, and the gravity will cause the user to slow down as they move up and then slowly speed up as they fall back down. When they hit the ground, gravity resets to 0.

And thats it. Call the movement routine before gravity, and the oldxyz data before the movement. Get the new xyz after gravity, and call the collision function after that. The gravity wont bypass the collision, and because it's reset every time you touch the ground, you'll be able to move up ramps. The only problem now is that you might be able to walk up some ramps that are too steep (ones you shouldn't be able to walk up). Its fixable as well, but worry about that when you get to that point.

Remember, jump speed is a negative, gravity speed is 0, and gravity rate is a really small, positive number, like 0.005, or maybe even 0.001.

- RUC'


Anto
17
Years of Service
User Offline
Joined: 30th Oct 2005
Location: Brisbane, AUS
Posted: 12th Aug 2007 03:05
G'day,

I know this is DB pro section, Ruccus, wondering if you could have any examples for Classic version as I like to understand and learn more about those sparky's Collision, Any chance that pool game example you did on first post runs on classic with few changes?

Thanks, Anto
RUCCUS
18
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 12th Aug 2007 03:14
Probably, what commands need to be replaced? I dont have DBC so I dont know what things were changed, but if someone posts with all of the things that need changing, I'll write it up tonight or tomorrow.


Anto
17
Years of Service
User Offline
Joined: 30th Oct 2005
Location: Brisbane, AUS
Posted: 14th Aug 2007 09:41
What kind this you need to know?

Login to post a reply

Server time is: 2023-02-05 20:03:20
Your offset time is: 2023-02-05 20:03:20