Example usage for com.badlogic.gdx.physics.box2d Body getLinearVelocityFromLocalPoint

List of usage examples for com.badlogic.gdx.physics.box2d Body getLinearVelocityFromLocalPoint

Introduction

In this page you can find the example usage for com.badlogic.gdx.physics.box2d Body getLinearVelocityFromLocalPoint.

Prototype

public Vector2 getLinearVelocityFromLocalPoint(Vector2 localPoint) 

Source Link

Document

Get the world velocity of a local point.

Usage

From source file:com.nuliy.example.Car.java

public void KillOrthoVelocity(Body body) {
    Vector2 localP = new Vector2(0, 0);
    Vector2 velocity = body.getLinearVelocityFromLocalPoint(localP);

    float r = body.getTransform().getRotation();
    Vector2 sideways = new Vector2((float) -Math.sin(r), (float) Math.cos(r));
    sideways.scl(velocity.dot(sideways));

    body.setLinearVelocity(sideways);/*  w  w w.java 2 s  . co m*/
}