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.

3 Dimensional Chat / Ball Bouncing (frustrated!)

Author
Message
Shogun Blackbrunei
21
Years of Service
User Offline
Joined: 1st Nov 2003
Location: Imaginary World
Posted: 16th Aug 2005 02:04
Hi all, I'm currently working on a game and I've been stuck with this one thing for quite some time now. My game is made out of a 3d map with 4 walls in it (formed in a square) and I have a ball in it. Now what I want is to make the ball bounce of the walls like a real ball would, I've been through the forums and codebase a lot of times but all I found were solutions for 2d ball physics. Mine, however is completely 3d and I have no clue at all how to do this. I so far have some code which does not really do what I want it to do. Does anyone have a good solution to this problem?


To subdue the enemy without fighting is the highest skill...
dark coder
22
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 16th Aug 2005 16:23
download newton physics dll, one of the examples has just what your talking about theres a room with 5 walls and you can throw a ball across it and stuff.


Shogun Blackbrunei
21
Years of Service
User Offline
Joined: 1st Nov 2003
Location: Imaginary World
Posted: 16th Aug 2005 18:05
I have tried using the Newton DLL but it sometimes just crashes (no clue why)...
Is there perhaps any way to do it with normal DBPro code?
Any suggestions are welcome

To subdue the enemy without fighting is the highest skill...
Sol462
20
Years of Service
User Offline
Joined: 12th Sep 2004
Location: playing with the spazookeedoo
Posted: 16th Aug 2005 22:53
Check out the Room sample with DarkBasic. There's code for a bouncing ball. Looks pretty realistic too.

Shogun Blackbrunei
21
Years of Service
User Offline
Joined: 1st Nov 2003
Location: Imaginary World
Posted: 17th Aug 2005 01:21
Well I allready doublechecked the help files and I indeed found an example showing how to make a ball bounce... up and down.
However, I have been trying to figure out how to make a ball return from a wall in the correct angle, which is where I am stuck with. And as I can't use the Newton SDK I am still stuck with this problem that has been bothering me for quite a while now

To subdue the enemy without fighting is the highest skill...
Sol462
20
Years of Service
User Offline
Joined: 12th Sep 2004
Location: playing with the spazookeedoo
Posted: 17th Aug 2005 19:03
Yea the ball in the Room demo can bounce of of the wall too.

Shogun Blackbrunei
21
Years of Service
User Offline
Joined: 1st Nov 2003
Location: Imaginary World
Posted: 17th Aug 2005 19:19
Then I guess you must mean a different example than the one I am seeing at this very moment, the example only repositions the ball when it hits a ground, it doesn't calculate the angle of return...
If the example that you mean does actually show how to solve my problem, would you be kind enough to post it?
Thus far I am still stuck with this problem...

To subdue the enemy without fighting is the highest skill...
Shogun Blackbrunei
21
Years of Service
User Offline
Joined: 1st Nov 2003
Location: Imaginary World
Posted: 17th Aug 2005 19:43
I have also tried to detect collision on every wall seperately, then convert it to an angle-range between 0 and 180 and substract the current angle from 180 to get the angle of return. However, this did not seem to do anything at all... the object doesn't change it's angle somehow

To subdue the enemy without fighting is the highest skill...
dark coder
22
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 17th Aug 2005 21:40
bah, just use the simple method have a x,y,z velocity for your 'ball' then if you hit a wall on the x axis then flip the x velocity maybe decrace it slightly aswell.


Shogun Blackbrunei
21
Years of Service
User Offline
Joined: 1st Nov 2003
Location: Imaginary World
Posted: 17th Aug 2005 21:48
That's not exactly what I want
But I downloaded the DB Trial and found the room example that Sol462 was talking about... pretty much code for collision though

To subdue the enemy without fighting is the highest skill...
Sol462
20
Years of Service
User Offline
Joined: 12th Sep 2004
Location: playing with the spazookeedoo
Posted: 18th Aug 2005 05:56
It's the one with the scorpion in it. The ball physics seemed accurate. I'll check it again.

Sol462
20
Years of Service
User Offline
Joined: 12th Sep 2004
Location: playing with the spazookeedoo
Posted: 18th Aug 2005 06:07
Object 102 is the scorpion, and object 21 is the ball, which is a sphere. Either object 5 or 22 is the room. Maybe the room and the door objects.
Try it out and tell me if it works, as I didn't write it.

Shogun Blackbrunei
21
Years of Service
User Offline
Joined: 1st Nov 2003
Location: Imaginary World
Posted: 18th Aug 2005 19:15 Edited at: 18th Aug 2005 19:17
Well I am trying ot figure it out, but as Lee used variables like wh#, ix#, iz# which seem meaningless on first sight, it will take me quite some time to get it working for my game
I will also never really understand what he did there

To subdue the enemy without fighting is the highest skill...
dark coder
22
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 19th Aug 2005 00:58
just use x,y,z velocitys like i said, theres nothing wrong with my method, just try it, continually move on object based on its velocity, just because its 3 more values doesnt mean its alot harder overall it gives t alot more flexibility then rotating it and moving it every loop..


Shogun Blackbrunei
21
Years of Service
User Offline
Joined: 1st Nov 2003
Location: Imaginary World
Posted: 19th Aug 2005 13:46 Edited at: 19th Aug 2005 13:50
I am not sure I understand what you mean, how would I be able to get an angle of return from velocities? I am sorry but I haven't used vectors or something like this before
I tried this before (modifying it to the right numbers for every wall)

Now I thought this would work fine (for 1 wall that is) but it seems to do nothing at all somehow...

To subdue the enemy without fighting is the highest skill...
dark coder
22
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 19th Aug 2005 15:15
never make an object move by its angle, unless its something like a bullet, simple fact is say you had a beach ball and you threw it forwards you might want to make it spin in midair but if you move it based on its angle then this becomes very tricky thus forcing you to make it follow its flight path which wouldent look very good,

using x,y,z velocitys you can have a ball fly up and arc down while the ball is spinning ain any direction easily, and to get the angle to bounch the ball off just use sparkys ray casting dll or something as it can return he face`s angle iirc, and you can just use sin and cos to generate new x,y,z velocitys.


Shogun Blackbrunei
21
Years of Service
User Offline
Joined: 1st Nov 2003
Location: Imaginary World
Posted: 20th Aug 2005 12:59
Hmmm ok thanks, I'll try that

To subdue the enemy without fighting is the highest skill...

Login to post a reply

Server time is: 2024-11-27 16:54:39
Your offset time is: 2024-11-27 16:54:39