How do I get magnitude variable of the box2d physics?

0 favourites
  • 6 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • I want comparing magnitude variable with a another local variable for the checking a if statement.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Why dont come answer for this question maybe nobody dont know what is magnitude or why?

    Sory guys but i now are very fustraded. 😢

  • It isn't really reasonable to want an answer within a half hour. Your question isn't clear, do you mean you want to get the speed of an object? You can calculate it with the Pythagorean theorem and the x and y velocities. Maybe this topic may help:

  • I dont want math.

    in unity game engine is possible.

    float maxcollisionpower = 8f;

    float sqrmaxcollisionpower = maxcollisionpower * maxcollisionpower;

    if (obj.velocity.sqrmagnitude == sqrmaxcollisionpower)

    I this want in c2. Possible?

  • But what you replied with is math too, and actually it's basically the the same as what I referenced.

    Velocity is a vector. Or basically it has a x and y value. The magnitude of a vector is it's length which can be calculated with the Pythagorean theorem:

    sqrt(sprite.physics.velocityX^2 + sprite.physics.velocityY^2)

    Or just use the distance expression, which does the same thing:

    distance(0, 0, sprite.physics.velocityX, sprite.physics.velocityY)

    In your example the "sqr" means the value is squared so that would be this:

    sprite.physics.velocityX^2 + sprite.physics.velocityY^2

    or this

    distance(0, 0, sprite.physics.velocityX, sprite.physics.velocityY)^2

    just repace "obj.velocity.sqrmagnitude" with one of those.

  • Understand thanks your answer but in the c2 box2d physics why not maked defaultly magnitude and sqrmagnitude for a better physics? And in the unity why is? Magnitude is a often used members.

    I do not like to code and math therefore I like c2 but I often feel that c2 expressions and built in members very few.

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