How do I fake physics collision redirection?

0 favourites
  • 12 posts
From the Asset Store
Simple yet very life-like rag doll made with Physics!
  • I'm experimenting with some physics-like movement without the Physics Behavior. I'm sure it's been done on here before.. can't find any examples though.

    I'm using basic Behaviors: CustomMovement and Bullet. I'm trying to redirect a 'block' based on speed/mass/angle of another block it collides with.

    I need to somehow not add additional speed to the collision. I'm using a one-time Acceleration action like 'force'.. although that may be a bad idea? not sure. All I really care about is the CustomMovement one.. the Bullet one I might just destroy and therefore not care about that trajectory/speed etc..

    I have to somehow take the speed of each object and it's angle to determine the force..since force cancellation would happen if angling directly toward each other - but also if going in slightly the same angle the only force would be the difference in speed. No idea how to do that.

    Maybe I am oversimplifying this... maybe there's a physics behavior for a reason?

    any help?

    https://www.dropbox.com/s/z0v2rkibaipnq ... .capx?dl=0

  • Yup that is why physics commands exist becuase it does all those complicated adjustments for you automatically if the settings are correct.

    You can do some pseudo-physics using the bullet behavior and it does have a gravity setting and velocity but determining impact speed is pretty complex.

    What kind of game are you making?

  • lamar there's no gravity.. just angles and speed - would like to use mass if possible. I have it sort of working without using mass.

    it does NOT work when the collision happen and the objects are going somewhat in the same direction - it just adds all this speed and does not look natural.

    just experimenting for a top down space game..

  • Try this:

  • MPPlantOfficial yup already downloaded that old Yann example.. gravity is not needed..just outerspace collisions. I couldn't figure a way to apply it.

    I probably need to use sin and cos.. . just don't know really how...

  • lamar there's no gravity.. just angles and speed - would like to use mass if possible. I have it sort of working without using mass.

    it does NOT work when the collision happen and the objects are going somewhat in the same direction - it just adds all this speed and does not look natural.

    just experimenting for a top down space game..

    I used the bullet behavior for one of my first pinball games and I was able to make it loook almost like real physics but like you said you could tell it was not natural physics and when two bullets collide you get strange effects that don't look natural.

    You can use the Sine effect to some extent to get a more natural effect.

  • R0J0hound any chance you could recommend something? just curious if this is even doable or if its more complicated than I'm making it.

    I just want to figure out how to take into account the moving angles, speed and how that would effect the 'force' or one-off acceleration.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I can live with setting the Moving angle of the GreenBlock after a collision to:

    angle(BlueBlock.X,BlueBlock.Y,GreenBlock.X,GreenBlock.Y) - 180[/code:3ak5bxur]
    I just can't figure out how much to accelerate by.
    
    I started with some arbitrary numbers and found some that work for most collisions.  Then I tried to come up with a calculation that would fit those numbers.  Most of it works well.
    
    But it all fails in this one scenario where the BlueBlock is traveling right, and a GreenBlock is also traveling right but is going faster.  When it catches up to the BlueBlock, the move angles are correct, except my calc fails miserably by adding way too much speed to the BlueBlock.  My calculation doesn't account for trajectory.
  • This link explains the math of a physics bounce:

    https://gamedevelopment.tutsplus.com/tu ... medev-6331

    I always found it hard to fake physics because it never looks right.

  • (VB-VA)·n+j*(j*nmassA+j*nmassB)*n+e*(VB-VA)·n=0?(1+e)((VB-VA)·n)+j*(j*nmassA+j*nmassB)*n=0?j=-(1+e)((VB-VA)·n)1massA+1massB

    yup that's what I figured..

  • yeah I'm not trying to do actual physics calculations.. just trying to get it 'approximate' .. it's a video game, so it doesn't need to be a perfect simulation by any means. The background is moving and the camera is lerped, so there's a high fudge factor. The biggest issue is the one I mentioned where the vectors are similar. I need to add that to my calculation and I'll be fine with it.

  • ended up making this work..

    again it's "fake physics" under a controlled environment

    After Collision Accelerate by this much:

    (BlueBlock.Bullet.speed * BlueBlock.scale) * (min(50,anglediff(GreenBlock.CustomMovement.MovingAngle, BlueBlock.Bullet.AngleOfMotion)/3))[/code:2phzshzm]
    
    then I have a catch-all that makes sure the GreenBlock doesn't go beyond my top speed of 300 just in case I have a situation where it does add too much accel..
    
    this is all done based on "looks" and watching it for long periods of time.. now THAT is some hacky math!
    
    btw the GreenBlock is the "player" which never changes and has a top speed, so all the other obstacles are based on that constant.
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)