Collision problem with time scale > 1

0 favourites
  • 7 posts
From the Asset Store
Various Bell Sounds (from small to huge) / 35 Unique Clips / 2:46 minutes of audio
  • Hi all

    In my game I attempted to set the time scale to higher than 1. For example purposes, say I set it to 15 and have a 10x10 box moving from the left side of the screen to the right hand side, with a 5x5 box in the middle. It would appear that every tick the game would move the box 15 pixels to the right, teleporting it past any objects it might normally collide with at a time span of 1. In this example it causes the boxes to incorrectly not collide.

    Is there a way to increase the time span and not break the collisions? If this simply isn't possible by increasing the time span, does anyone know of another technique to speed the game up? Or am I on the completely wrong path and this should be working?

    Cheers

  • If you are using the physics behaviour, then i'd see if enabling 'bullet' mode in the properties would help. I don't know the details of it, but it basically gives the object more precise collision detection.

  • No physics in there now, but I'll add it and the bullet behaviour and see if it helps.

    Update: So I gave it a test and you are correct. The physics behaviour is not needed, but changing to the bullet behaviour does indeed collide with the object, regardless of the time scale.

    Sample demo:

    dl.dropbox.com/u/20830426/TimeScaleTest.capx

    The unfortunate part is I'm trying to apply this to an object that also has the "Platformer" behaviour, and adding both the bullet and the platformer behaviour causes it to no longer collide. Anyone have any idea why bullet would work but platformer would not? Is this by design?

  • sorry, I don't have an answer but i am compelled to ask why you'd want to set the timescale so high?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The time scale of 100 in the capx above was just for demonstration, to show that the bullet behaviour can collide correctly regardless of the time scale, but the platformer behaviour does not. In my actual game I'm trying get a 'fast forward' effect by setting the timescale to 5 or 6, but this has the same problem just on a smaller scale. Sometimes objects miss by a few pixels and go flying past :)

  • They both miss for me, I think it's just a coincidence that the bullet behavior hits and the platform doesn't.

    You have to manually check the positions the object moves over. You can do it by lerping from the old position to the new in a loop.

    every tick:
      +set newx to sprite.x
      +set newy to sprite.y
    
    repeat 11 times:
        +set sprite position to lerp(oldx,newx,loopindex/10),lerp(oldy,newy,loopindex/10)
      is sprite overlapping wall:
        + do something
    
    every tick
    [ul]
    	[li]-or--[/li]
    [/ul]start of layout:
      +set oldx to sprite.x
      +set oldy to sprite.y
  • Thanks R0J0hound, that does work. Good old lerp :)

    I'm not sure how I would go about applying this to everything on screen. It works well when you just have one or two items, but gets complex fast when you try to speed everything up. Unless there is a scalable way of doing this I might just have to put this feature on hold.

    It appears that some libraries like Box2D already take continuous collision into account (I assumed this was why the bullet behaviour was working because it implemented this), so it would be nice if this could be added to C2 Ashley if you are listening *bats eyelids*

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