Physics problem

0 favourites
  • 4 posts
From the Asset Store
Simple yet very life-like rag doll made with Physics!
  • On mouse click I create a new instance of an object with physics enabled at mouse x and y. The object is a plank 125 by 25, and the initial instance is set horizontally at 0� angle. (collision mask set to bounding boxes)

    The problem occurs when I want to spawn the same object at 270� vertically next to a wall. The created object gets pushed away as the initial instance was at 0� and only after its created changes to 270�.

    The event goes as following:

    On Left button clicked

    ->Create object Plank

    ->Plank set angle to x degrees

    Is there a way to overcome this problem?

  • Set up a boolean variable called "cursor distance", set it to True by default.

    Set up a System event to run every tick, calling check on the distance between your cursor and the wall. If the value is less than 125, the action of this event will set "cursor distance" to false.

    On your current event add the condition: Cursor distance=true

    Change your current event to an If statement.

    This is where I'm going to have to delve into even worse pseudocode, apologies, I'm a bit rushed atm :S

    Set the Else to create your plank object at mouse.y+ the distance from wall (Call it from a variable updated every tick?)

    Sorry, that went off badly and probably isn't much help! :(

    There's also likely a much simpler solution using origin points or something! Sadly I'm new

  • Would this work:

    Create plank at (-500, -500)

    Plank set angle to 270 degrees

    Plank set position to (mouse.x, mouse.y)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • ramones

    I tried that but the plank would randomly spin when positioned to mouse x, y.

    E Bear

    I'm not sure if I understood, but that wouldn't solve much.

    On the other hand, you gave me an idea.

    What if I would keep that initial instance (usually I would have it destroyed) and rotate that as the player chooses the angle at which to spawn the new object. With that the initial object would be at the same angle as the spawned object would need to be.

    UPDATE: apparently the current angle of the initial object doesn't matter, but the initial angle.

    It would be really nice to have a "at angle" option in the Create object action.

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