User Tag List

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 12

Thread: Physics Engine and Array Based Engine

  1. #1
    Clicker Fusion 2.5 (Steam)

    Join Date
    Jul 2014
    Posts
    92
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Physics Engine and Array Based Engine

    Hi Everyone,

    I have made my own scrolling engine car game in fusion and I want to have it work with the physics engine. My engine currently stores the positions of all objects in an array as floats. The problem is that I can't have my camera scroll smoothly with physics because the get position function in fusion only returns an integer when the physics object calculates a floating point position.

    Therefore my array of objects can't replicate what the physics engine is saying should happen. The only solution I can think of is making my own physics engine as the physics object will not give me floating point coordinates.

    What is the best way to solve my problem. My game is similar to spy hunter where you always scroll. It basically reads all objects and map items from an array and saves their position to an array as well.

    Cheers,

    Rocket

  2. #2
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export Module
    Fusion 2.5 (Steam)
    schrodinger's Avatar
    Join Date
    Nov 2014
    Posts
    3,155
    Mentioned
    27 Post(s)
    Tagged
    1 Thread(s)
    All actual X,Y positions are going to be integers, since pixels are integers,
    and so will be your camera position.

    Regardless of what you are using,
    a simple trick could just be calculating your "camera" position in a value that can hold floats,
    and then refer to that value for camera position.

    It will nevertheless move in integers, but its path will be built upon floats

    i.e.
    0,8 + 0,9 + 0,5 x frame = 2 pixel movements in 3 frames for float camera
    v.s. no movement (0+0+0) / or 3 pixel movement (1+1+1) for integer X-Y positioning

    thus looking much more fluid

  3. #3
    Clicker Fusion 2.5 (Steam)

    Join Date
    Jul 2014
    Posts
    92
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    I do perform this method. It's more that I need the float position based on the physics engine and the only way I can store positions and changes from the physics engine is by get an objects position which is in integers only. Even though the physics object is obviously calculating everything in floats.

    My camera moves properly it's just that I can't save the position of objects being moved by the physics object accurately. (i.e. Position per physic object is 12.235, position of object that I can get and save in my array 12 (as get position only returns integer)

    Physic object equals the physics engine object
    Object I am trying to get a position from is an active object.

    Array stores positions of all objects as floats
    Positions of objects updated based on the array float positions

  4. #4
    Clicker Fusion 2.5 (Steam)

    Join Date
    Jul 2014
    Posts
    92
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Example:
    Position of car in array 30.567
    Position of car object set to 30.567

    Physics engine object says it gets hit and should shoot off in to the left say 5.3 pixels

    I record the new position to the array based on what is happening on screen using get position

    New position in array 25.0 pixels (as I had to use the get position function)

    Repeating this process every frame creates major issues due to floating point to integer conversion issues.

  5. #5
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export Module
    Fusion 2.5 (Steam)
    schrodinger's Avatar
    Join Date
    Nov 2014
    Posts
    3,155
    Mentioned
    27 Post(s)
    Tagged
    1 Thread(s)
    Sorry, I didn't see you were already doing that

    The thing I don't get (probably due to my lack of knowledge in physics engine) is:

    I record the new position to the array based on what is happening on screen using get position
    If you already set float positions in objects values (>> probably not?)
    why don't saving directly those in the array?

    A quick example of basic dynamics you're using (just an object, phys. engine & a counter for displaying your int)
    would tremendously help receiving on the correct frequency
    and maybe thinking of a workaround...

  6. #6
    Clicker Fusion 2.5 (Steam)

    Join Date
    Jul 2014
    Posts
    92
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    "Why don't saving directly those in array"

    I can't, float point movements are calculated in the physics engine object. The result is my objects move from their inital location. My array just records what happened and where things should be.

    It can't record what happened accurately because the only way I can record positions is get position.

    The float movement that the physic engine is using to move my object and change its angle is hidden in a blackbox that I don't have access too.

    My array can't get these floating point positions as all I can do to record what the physic engine did is get the resulting integer position.

    Only solution I can think of is to custom physics calculations myself which is taking me forever

    Aka because I can't get floating point numbers from the physics object I have to recreate box2Dd from scratch using events.

    Aka I don't want to do this if I'm using fusion in the wrong way to achieve what I want.

  7. #7
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export Module
    Fusion 2.5 (Steam)
    schrodinger's Avatar
    Join Date
    Nov 2014
    Posts
    3,155
    Mentioned
    27 Post(s)
    Tagged
    1 Thread(s)
    So your array is always saving those values from actual object X/Y position...

    and I guess this is not a single timed "save to array" feature (otherwise the problem would be negligible),
    but you actualy base your app on those numbers in real time for making other calculations (camera position?)

    Mmmm unfortunately *It seems* there are no "direct" ways to get X-Y positions as floats, even if physics thinks in that way.

    I understand re-doing physics could be the only way... and maybe it shouldn't be that dramatic if your movements are simple,
    but I can feel your pain

    The only thing you could (maybe) rethink, is this "array-continual-need" to store those positions,
    is this absolutely necessary? What does this setup serves for?

    Other (much more complicated!) idea could be thinking the same way as physics engine does
    i.e. retrieving and applying impulse-direction-etc. on EVERY frame
    FROM starting float position
    so that recreating the "vectorial path" of the object you could stay "updated" on its float position
    instead of saving its resulting position

    ...but this would imply a deep knowledge of the engine,
    don't know if such documentation is available...

    and maybe ultimately It could be easier setting up a simpler custom engine as you were already thinking

  8. #8
    Clicker Fusion 2.5 (Steam)

    Join Date
    Jul 2014
    Posts
    92
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    The world and it's objects move around the player. Rather than the player moving through the world. Thus I need the object's locations stored in an array as if they get too far off-screen they get destroyed.

    Since everytime the player moves the camera moves. Thus every physics object's position is set to its position + camera movement every frame. Thus creating the rounding error problems.

    At the end of the day my car game needs to be constantly scrolling. And I want collisions where cars will bounce and rotate realistically off each other.

    Same with pylons the player woulld drive through. It all works great when the camera doesn't move. As soon as it does it goes to poo.

    As for making my own physics to replicate rotation box collisions and determining the penetration of collisions and optimizing for spatial partitioning that would be required it would add months and definitely be buggy.

    There has to be a way for clickteam to at least make a simple function to grab the float position of an object.

  9. #9
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export Module
    Fusion 2.5 (Steam)
    schrodinger's Avatar
    Join Date
    Nov 2014
    Posts
    3,155
    Mentioned
    27 Post(s)
    Tagged
    1 Thread(s)
    This probably could be simple for clickteam, hope there could be a solution on this side.

    Just another idea to test, If you didn't already,
    you could try experimenting with the "display factor" on the "physics engine" properties:

    Display factor
    The Box2D engine works with meters and kilograms. Clickteam Fusion 2.5 frames work with pixels. This property contains the multiplication factor to apply to Clickteam Fusion 2.5 coordinates when transfering them into the physical world. A value of 32 means that a 32 pixel-wide object will have a width of 1 meter in the world.
    The value of 32 works for the majority of the games you can create. But if your game contains very big objects, the physical engine may not be able to cope with them. You should therefore, change this value depending on the size of your objects. A higher value reduces the size of the objects in the physical world. A smaller value increases them.
    Also note that, as a result of the calculation, objects will seem to move faster on the frame with lower values of this property.

  10. #10
    Clicker Fusion 2.5 (Steam)

    Join Date
    Jul 2014
    Posts
    92
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    I'm not fully understanding how this factor would help me in my situation. Wouldn't changing that value move items further apart from each or closer together? Could you help me understand?

    Is there anyone from clickteam on this forum that could add the feature of returning an object's floating point position from the physics engine object?

Page 1 of 2 1 2 LastLast

Similar Threads

  1. Why is physics engine not timer-based?
    By MJK in forum HTML5 Export Module 2.5
    Replies: 3
    Last Post: 31st March 2015, 04:00 AM
  2. Replies: 5
    Last Post: 31st August 2014, 02:58 PM
  3. Possible to make some simple object fall physics without physics engine?
    By Outcast in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 3rd March 2012, 08:56 AM
  4. Timer-based static engine
    By DistantJ in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 14th February 2012, 06:44 PM
  5. grid based platform engine
    By Gabriel in forum File Archive
    Replies: 13
    Last Post: 26th July 2006, 07:23 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •