How do I retireve physics properties after drag and drop

0 favourites
  • 2 posts
From the Asset Store
Use inertion of your movements to throw, rotate your objects and etc. Objects can interact with others while dragging.g
  • I have a power up that when the player touch the screen, the time is frozen and then he can drag and drop the object. This object has physics behavior, which lose all it's properties like velocity, direction, etc when dragged.

    I thought about getting all of this and store it in a variable. However, we have expressions to retrieve angular velocity, center of mass, mass, and velocityX and Y, but not the overall velocity.

    Summing up, after dragged and set scale time to 1 again, the object doesn't keep the velocity and direction, it drops straight down.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • So, yes, you're going to need to store the variables. I've not worked with physics objects since Construct classic though. I assume that only the velocity is lost on this time freeze.

    Have two instance variables in the object labelled velocityx and velocityy or any other names which mean the same. When the time is frozen, set the variables to the objects x velocity and y velocity. When time is resumed, use the object.setvelocity using the parameters of the stored velocity x and y.

    This works because a velocity can be split into its components, in however many dimensions you are working with. In this case we are on a plane so we need to consider only x and y. Using trigonometry we can look at an objecs velocity in terms of a line, where the length of the line is the velocity and the direction the line is pointing is the direction of velocity. Since the line is straight and in the plane then we can calculate the velocity in both x and y velocity. This is also true in reverse with the overall velocity equalling sqrt(vx^2 + vy^2) which is synonymous with pythagoras' theorem.

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