Page 1 of 2 1 2 >
Topic Options
#124629 - 01/16/09 10:26 PM Custom marble movement debugging
JimJam


Registered: 06/30/06
Posts: 49
I'm trying to build a simple ball physics engine for use in my next game. I like what I've got so far, but something just doesn't feel right about it. I don't know if its my approach that's wrong or my application.

What I'm working to achieve is a simple table-top physics system. Right now I'm trying to replicate marbles or billiards physics. Something dealing with applying forces, pushes, or pulls to an object and having react accordingly.

The first 3 frames are just my math test frames. They were a learning experience, and I've left them so you can see my logic.

The next frame is a maze with wind fields and blockers. The wind doesn't seem to work right, as it will keep reapplying force. I could use some help here.

The last frame is the same as above, but where the ball just loops around the frame with no obstacles. Also a "marble shoot" test.

I can see whats wrong with the programming, but I don't know what to do to fix it. The problem is, that if you push an object with a force of 2 west, and then another force of 2 west, it doesn't equal a force of 4 west because the object is already moving at 2 west. Therefore another push at a force of 2 west wouldn't even push it at all, because both objects would be moving the same speed. I'm not sure if I need to subtract the difference or what here.

I could use some pointers.
I've used the function egg-timer extension.
Feel free to use my app for your own learning purposes.


Attachments
Vector Force 3.mfa (46 downloads)


Top
#124643 - 01/17/09 01:33 AM Re: Custom marble movement debugging [Re: JimJam]
Johnny


Registered: 06/21/07
Posts: 87
Nice !

Top
#124661 - 01/17/09 03:59 AM Re: Custom marble movement debugging [Re: Johnny]
JimJam


Registered: 06/30/06
Posts: 49
Thank you. My goal was to emulate clickteam's vector movement. Clickteam's vector movement is really nice, but I felt like I didn't have full control over all the features I needed, and I didn't fully understand its mechanics and values.

While mine isn't as powerful or simple to implement, it gives me the sense of control I want in knowing exactly what is going on.

Top
#124745 - 01/17/09 12:21 PM Re: Custom marble movement debugging [Re: JimJam]
_LB


Registered: 06/07/07
Posts: 887
Loc: Richardson, Texas, America.
I think the forces should add on, look up some physics about how NET force works and such, when an object collides with another it has to be moving faster than the one it collides with, so basic way of doing it is to swap the forces, the fast one gets the slow one's speed, and slow one get's the fast one's speed.
_________________________
Check the awsome games at http://ragdollsoft.com/
~Multimedia Fusion 2 Standard User~
My Site - LB-Stuff
-LB

Top
#124814 - 01/17/09 04:34 PM Re: Custom marble movement debugging [Re: _LB]
JimJam


Registered: 06/30/06
Posts: 49
From what I have learned, the net force IS the total vector sum of all acting forces...

A quick google search agrees (assuming these pages are correct):
http://id.mind.net/~zona/mstm/physics/mechanics/forces/netForce/netForce.htm
http://www.glenbrook.k12.il.us/GBSSCI/PHYS/CLASS/newtlaws/u2l2d.html
http://en.wikipedia.org/wiki/Resultant_force

See, they tell me I'm doing the addition just fine. But I think there is a problem with how my wind force works. See, the vector addition works fine when applied once in a forceful shove. That is, 8 + 2 = net force 10.

In reality, when you apply a constant force of 5 to an object (as an example, pushing a car), it would move at 5 (assuming mass is irrelevant).

But in my MMF2 game logic, the inputting force acts once per game frame. That is, each frame the force of 5 would be adding on each frame... making frame 2 10, frame 3 15. And at 60 FPS, after one second the object would be accelerating at 300. Which is not correct.

I think my game logic is fine for single input forces, such as collision, but constant forces like wind will cause a massive acceleration by adding each frame...

There must be some way I can limit them... maybe by using the eggtimer.

Top
#124822 - 01/17/09 05:14 PM Re: Custom marble movement debugging [Re: JimJam]
Looki


Registered: 08/27/06
Posts: 975
Loc: Duisburg, Germany
Frames 2, 4 and 5 crash for me :S

Top
#124825 - 01/17/09 05:46 PM Re: Custom marble movement debugging [Re: Looki]
JimJam


Registered: 06/30/06
Posts: 49
Do they crash on start up, or just in the middle of play? I can't imagine what would cause the crash...

Top
#124827 - 01/17/09 05:50 PM Re: Custom marble movement debugging [Re: JimJam]
Looki


Registered: 08/27/06
Posts: 975
Loc: Duisburg, Germany
On start-up. Me neither. Frame 2 is pretty simple...

Top
#124828 - 01/17/09 05:56 PM Re: Custom marble movement debugging [Re: Looki]
JimJam


Registered: 06/30/06
Posts: 49
Huh, I'll keep that in mind... Though I don't really know what to do about it.

Top
#124879 - 01/17/09 08:28 PM Re: Custom marble movement debugging [Re: JimJam]
_LB


Registered: 06/07/07
Posts: 887
Loc: Richardson, Texas, America.
Originally Posted By: JimJam
There must be some way I can limit them... maybe by using the eggtimer.


Uhh, no. Eggtimer is for making timer events, just test if it is already at the speed, or use Nifflas' object and uset the min/max expression.
_________________________
Check the awsome games at http://ragdollsoft.com/
~Multimedia Fusion 2 Standard User~
My Site - LB-Stuff
-LB

Top
#124907 - 01/17/09 11:54 PM Re: Custom marble movement debugging [Re: _LB]
JimJam


Registered: 06/30/06
Posts: 49
I'm trying to keep the system extension free. Unfortunately, my engine requires that I use functions to prevent repetition of complex events. Though I suppose I could use a 1 loop Fastloop as a function, but I need it to call immediately, and I haven't tested if it works.

I am also trying to keep the system independent, so it can be run in a behavior or applied to multiple objects.

And no, testing if its at the current speed won't work. With vectors its hard to just say if its at a certain speed or not because it also has a direction. I'd have to find some method of comparing direction too. That wouldn't actually fix the problem and would be a work around.

The issue is that the vector keeps adding every single game frame, and it adds too fast. I did do a test that sort of worked by simply putting a delay between the forces, but the delay has to be proportional to the force, otherwise you have the same issue of being a work around.

Top
#125080 - 01/18/09 09:28 PM Re: Custom marble movement debugging [Re: JimJam]
_LB


Registered: 06/07/07
Posts: 887
Loc: Richardson, Texas, America.
What formula do you use to calculate how far to move it? Use that to get the X/Y movement and just compare X and Y separatly. Also fastloop does run instantly upon calling in the middle of lines of events, then when it's over it resumes from where it left off.
_________________________
Check the awsome games at http://ragdollsoft.com/
~Multimedia Fusion 2 Standard User~
My Site - LB-Stuff
-LB

Top
#125084 - 01/18/09 10:06 PM Re: Custom marble movement debugging [Re: _LB]
JimJam


Registered: 06/30/06
Posts: 49
Thanks for the info on the Looping. Hey, is there a way I can name a loop a Fixed Value, and compare it to an object to form association? Or maybe some other form to associate loops to specific objects, or multiples of objects?

I'm using a simple distance formula, to convert an angle and magnitude into an X/Y Magnitude. You know, sine and cosine, and what not. Did you look at the file?

Either way, I tried a method which compares the X/Y individually, but that would have to compare the coordinates at each instance of "impact". It just didn't work. Also, since negative numbers are less than zero, moving in the opposite direction would compare as being lower than the current speed, not equal. I could compare them using the Absolute value, but then without negative numbers you couldn't tell which direction you were travelling in. The only work around would be to compare the absolute value for numeric purposes, and use the real value for directional purposes. But that would be redundant and probably take a hit to the FPS. It just didn't work in all situations, only some.

I have found a method that works. Its a simple Acceleration formula.

Just set the speed to this:
(value( "Top Speed" )-value( "Actual Velocity" ))*value( "Accel" )

In which case Top Speed would be the desired speed to reach, actual velocity being the current speed of the player, and Accel being some decimal coefficient (in my case, 0.25). This will add to the Actual Velocity by a fraction of the difference of the two. While technically this acceleration would create an opposite parabola that would be considered deceleration... it works for my purposes.

But yet another glitch arises.

For some reason, at speeds lower than 1, turning at a right angle will set the Y speed in the thousands! It only applies as long as you hold the direction key, so it seems to be a fault of the deceleration formula I'm using. I'll figure it out and upload a new version.

Top
#125130 - Yesterday at 10:48 AM Re: Custom marble movement debugging [Re: JimJam]
_LB


Registered: 06/07/07
Posts: 887
Loc: Richardson, Texas, America.
For the first part of your post, just use Compare to active Objects value = Loopindex

Also, can't you just use compare two general values and use to conditions, one is the max speed, one is greator than 0, opposite for going left, ect...

Sorry I really just think logically rather than doing sometimes.
_________________________
Check the awsome games at http://ragdollsoft.com/
~Multimedia Fusion 2 Standard User~
My Site - LB-Stuff
-LB

Top
#125292 - Today at 02:18 AM Re: Custom marble movement debugging [Re: _LB]
JimJam


Registered: 06/30/06
Posts: 49
Quote:
For the first part of your post, just use Compare to active Objects value = Loopindex

Ooooh, I know what you mean. Thanks.

Quote:
Also, can't you just use compare two general values and use to conditions, one is the max speed, one is greator than 0, opposite for going left, ect...

...Hmmm... I think I see what you are saying here, but I'm a little confused. Could you clarify? If I understand what you are saying, I don't think it would work, because technically my movement system would have to to have an event for all 4 directions and combinations for the directions. Well, it would work (I think) but would require lots of hard coding for direction checking.

Here is my updated file. Check it out and see. If you run into the eastward wind while facing down and holding shift (run key), it reacts just fine, but if you go in without holding shift and facing down, it will flip you around and super accelerate backwards. I'm not sure whats causing it, but its got to do with the acceleration formula.

Oh, I also looked at your site. "The way I think" totally describes me. Even the thing about perpetual magnets and perfect tune music memory!

EDIT: I fixed the problem. The problem was when changing from a higher top speed to a lower one. Now I've set the top speed to change to the higher of the speeds. Still having a bit of trouble with the wind. I've included the updated file, which also has an acceleration grapher.


Attachments
Vector v3.mfa (5 downloads)



Edited by JimJam (Today at 05:01 AM)

Top
#125314 - Today at 07:32 AM Re: Custom marble movement debugging [Re: JimJam]
_LB


Registered: 06/07/07
Posts: 887
Loc: Richardson, Texas, America.
The game's coming out really nice, the wind problem seems fine to me, or is that what you fixed? I got all the way through the level and only encountered one bug, the thing that spurts out balls, I was behind it and got sucked into it and bounced at and angle against the wall and instead of bouncing normally I bounced by plus 180 degrees. Everythings seems pretty nice so far, maybe just some smoothing.

And glad to see somone who thinks like me!
_________________________
Check the awsome games at http://ragdollsoft.com/
~Multimedia Fusion 2 Standard User~
My Site - LB-Stuff
-LB

Top
Page 1 of 2 1 2 >


Site Links
Forum Index

Home Page
Online Store
Tutorials
Download Center
French Forum
Quick File Links
Multimedia Fusion 2
Updates - build 248
Standard Version
Developer Version

Extension Packs
Bonus Pack 1
Bonus Pack 2
z33z Extension Pack
LIJI Extension Pack

The Games Factory 2
Latest Update - build 248
Community Links
Madword Arcade

GameBuilder
Fusion2Developers
The Daily Click

Extensions
Neatwares Extension List
Extension Updater (FusionUpdater)
Zoom Gamer
Click Chat
6 People are chatting