Physics and Vsync Problem

This forum is currently in read-only mode.
From the Asset Store
Simple yet very life-like rag doll made with Physics!
  • So--

    I have bullets with Physics Behavior in my game. (Needed for how the bullets interact with the Physics ships they hit.)

    Right now, if the player shoots a bullet and it leaves the screen it will WRAP around to the other side using the included CC "Wrap" behavior.

    This all works perfectly, until I turn on Vsync at 60 FPS.

    Then suddenly, the bullet will no longer wrap at the edges of the screen, it'll just hit the edge and keep bouncing.

    I ran into a similar problem before with the player's ship (also a Physics object.) In that instance, I was told to turn off the Wrap Behavior in Construct Classic and just "roll my own."

    Like so:

    + System: Ship2.Y Lower than -10

    -> Ship2: Set 'Ship2VelX' to Ship2[Physics].VelocityX

    -> Ship2: Set 'Ship2VelY' to Ship2[Physics].VelocityY

    -> Ship2: Set immovable: Yes

    -> Ship2: Set Y to 1205

    -> Ship2: Set immovable: No

    -> Ship2: Set velocity to (Ship2.Value('Ship2VelX'), Ship2.Value('Ship2VelY'))

    Works great, but there is only ONE ship per player. With the bullets, a player can shoot up to FIVE at any given time, all created from the same sprite...

    I tried a version of the above with a "For each Object" event. The first bullet wrapped perfectly, the others following behind it suddenly slowed to a crawl (something, I think, to do with the fact that they all share the same private variables?)

    So, I'm looking for a way to:

    A)figure out how to ID each individual instance of the bullet and

    B)store it's current Velocity in a unique private variable.

    Or, barring that, IS there another way to wrap a physics object in CC?

    Should I just forget about vsync and leave the frame rate set to "Unlimited"? (This is not a commercial game, so it might not matter in the long run.)

    Am I going about this all wrong?

    Any advice greatly appreciated...

    Thanks!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I actually got this working.

    The problem was, I think, that the wrap needed a few pixels of padding from the edge of the frame. Not sure why, but this (done for all 4 sides) worked:

    + System: For each Bullet1

    + System: Bullet1.X Lower than 3

    -> Bullet1: Set 'VelY' to Bullet1[Physics].VelocityY

    -> Bullet1: Set 'VelX' to Bullet1[Physics].VelocityX

    -> Bullet1: Set immovable: Yes

    -> Bullet1: Set X to 1917

    -> Bullet1: Set immovable: No

    -> Bullet1: Set velocity to (Bullet1.Value('VelX'), Bullet1.Value('VelY'))

    Thought I'd put it up here in case it's useful for anyone. The big take-away for me was that the Physics Behavior works differently depending on weather or not you have Vsync turned on. (I guess that's to be expected.)

    Thanks!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)