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.

DLL Talk / Newton - ball not rolling backwards

Author
Message
Adam D
18
Years of Service
User Offline
Joined: 8th Jun 2006
Location:
Posted: 25th Jun 2006 16:06
I've had a search through the forums and looked through the newton demos but I can't find a solution to my current problem so I apologise if this has already been answered and I've just missed it.

I'm making a small mini golf game and I have a series of ramps in my level (they're just boxes that I've rasied one edge of in 3D Canvas).However, when I fire a sphere up the ramp, if it doesn't make it to the top it just gets stuck to the mesh and doesn't roll back down the slope. If the ball makes it to the top of the ramp and bounces off a wall then it rolls quite happily down the ramp. It only happens if a ball makes it half way up.

I use the following code to create the static mesh:



Then I use the following code to fire the ball (for which I've created a dynamic newton object using code similar to the one above). I use the following function to fire the ball:



I then use the following code to run the update the ball movement:



I've created the static mesh before this section of the code. I'll post the full source if I have to but it's still in a fairly rough state and it's a little awkward to get to the correct section (in order to see the problem). I know it isn't the model that is the problem because I've tried several different models and they all suffer from the same issue.

I've also tried setting up different materials and adjusting friction values to see if that is the problem (didn't help), I've tried adjusting the gravity and mass of the ball (didn't help), I've tried setting the solver and friction models to more realistic modes (didn't help) and I've tried increasing the amount of polygons in the object in order to increase the amount of contact points (that was a vain attempt and needless to say didn't help).

Sorry for the long post but I'm trying to be as thorough as possible in the hopes that someone has the answer.

Thanks,
Adam
CuCuMBeR
21
Years of Service
User Offline
Joined: 11th Jan 2003
Location: Turkey
Posted: 27th Jun 2006 14:10
as far as i see, you are Setting forces not adding them.
and i think you are setting forces during all the loop not once when you strike the ball.so when the ball hits to the ramp, you still keep setting a constant force to the given angle while the ball should slide back down the ramp aand somehow these are equal forces that keep the ball static.
but that may not be the issue, thats what i just think with an overview look at the code. try debugging your newton world too to see if theres somethin wrong with the collision data.
Finally it has nothing to do with newton, but you may just want to check this ballistic trajectory code.
And check this for applying forces to newton objects.

Aaaand i liked the golf game idea,if i try to make my own golf game too, then would you think it as stealing your idea?
good luck with yours
Adam D
18
Years of Service
User Offline
Joined: 8th Jun 2006
Location:
Posted: 27th Jun 2006 18:38
I've tried out some of the suggestions there and in the other links and it hasn't had any effect on the ramp collision problem. However, it was very helpful as it showed me how to refine the ball movement which helped iron out some other problems I was having, so thanks for that

I am having a slight problem adding a force to the ball, I'm using the following code to apply the force.


I placed this just before the main loop (the one in the my post above) and I've tried placing it in the loop but it doesn't appear to do anything. The ball just sits there, I'm missing something.

Thanks for the help and I don't mind if you do a golf game (I don't think anyone would believe me if I claimed that golf was my idea ). Looking forward to seeing your attempt.
CuCuMBeR
21
Years of Service
User Offline
Joined: 11th Jan 2003
Location: Turkey
Posted: 28th Jun 2006 18:05
as i cant see the whole code, i cant say much and On the other hand, you better not post all of your code because i might steal
One thing i can say is, try checking if the ball is frozen or not before applying forces. even if you force the ball, it wont move if its frozen.
Adam D
18
Years of Service
User Offline
Joined: 8th Jun 2006
Location:
Posted: 28th Jun 2006 22:43
Steal away I don't mind putting the full source up, I'm more interested in learning (this is the my first game project other than some simple text based stuff). The reason I didn't put it up straight away was because the media was just a bunch of grey plain and shapes that only I could understand

Attachments

Login to view attachments
Adam D
18
Years of Service
User Offline
Joined: 8th Jun 2006
Location:
Posted: 28th Jun 2006 22:47
Oh forgot to mention, you control with the mouse - hold down the left mouse button to build up power and release it to set the power, hold down the right mouse button to move in and out. I've taken the materials bit out of the code for the moment as I was having trouble with one of the courses.

To see the problem I'm having, line up the ball with the first ramp (on course 1) and fire with a power of around 16 - 20, it should get stuck half way up and not roll back.
CuCuMBeR
21
Years of Service
User Offline
Joined: 11th Jan 2003
Location: Turkey
Posted: 29th Jun 2006 00:26
Oh well, that is alot of code. And that is alot of loops with while-endwhiles and repeats..

you do have a different loop for any case, im so dizzy.


Anyhow I dont have a solution for you but i can show you how you can see what you are doing wrong, add the following to the bottom of your main.dba file.


And Then change your shooting loop i think it ends at the line 570 where i found a sync there.
Change it with the following line:


now when you run your code, at the time when you are changing the shooting angle and prepare to shoot, at that screen press F12 key to debug newton world,(just a side note, your level mesh needs optimising ive to say) anyways you will see the newton world, but you wont be able to see the ball in that world.
and when you shoot, the newton debugging disappears thats because you go out of the loop which is considered to be the main loop and you jump into a completely different loop. Which i presume stops newton environment completely so theres no reaction from the ball.

Anyways im not sure if i can fix your code, its too dizzy with all those loops..And you have functions for everything,try gosubs..

what i can suggest is 2 loops
1 for the menu
2 for the main game loop
and 1 goto command whenever you have to reset things and to go back to 1st loop
Hope this helps.
Adam D
18
Years of Service
User Offline
Joined: 8th Jun 2006
Location:
Posted: 29th Jun 2006 10:40
It does help, thanks. I do need clarification on certain programming structures and methods (as I'm new at all this) but that is not appropriate to this thread so I may start a new thread later in the DBPro forum and the 3D Canvas Pro forum (about the level mesh). Thanks again.
RaceGT
19
Years of Service
User Offline
Joined: 15th Aug 2005
Location:
Posted: 30th Jun 2006 04:44
Just a quick observation to this thread: if you are using Newton, you shouldn't be setting any forces on the objects, as that's what Newton is supposed to handle. If you go setting them to specific values, then it will probably get messed up. At most, I'd say the most interaction you'd have with the objects is that while reading the parameters of the object(s), if you notice a specific condition arise, then you might take action and actually set the specfic force(s) on an object. But other than that, they should be just reacting freely, according to the properties you've set for them (friction, mass, etc.). I think that's the way you'll get the best, most natural response from the physics.

http://www.geocities.com/crmnlelmnt/

Login to post a reply

Server time is: 2024-11-22 06:19:32
Your offset time is: 2024-11-22 06:19:32