Forums

OverviewV-Play 1 Support › Rotate enitity with box collider

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #6336

    Caeser

    How do I set the rotation of an entity that has a BoxCollider? I want to make sure that the BoxCollider rotates correctly with the entity.

    Also, I want to rotate the object on its center.

     

    EntityBase {
        entityType: "satellite"
        entityId: satellite
        id:satellite
    
    
        Image
        {
            id:asteroidImage
            width: 300
            height: 80
            source: "images/test satellite.png"
        }
    
        BoxCollider
        {
            id:collider
            width: 300
            height: 80
            fixedRotation: false
            
            //HOW TO SET ROTATION OF COLLIDER AND ENTITY?
    
        }
    
    
        MovementAnimation {
            target: parent
            property: "pos"
    
            velocity: Qt.point(-200, 0)
    
            // start running from the beginning
            running: true
        }
    
    
    }

     

    #6337

    Alex
    V-Play Team

    Hi,

    you can simply set the rotation property of the entity. If you want to rotate the object on it’s center, you will have to move the children of the EntityBase left and up by half their width/height, since Box2D does not support the transformOrigin property.

    EntityBase {
        entityType: "satellite"
        entityId: satellite
        id:satellite
        rotation: 45
    
        Image {
            id:asteroidImage
            width: 300
            height: 80
            x: -width/2
            y: -height/2
            source: "images/test satellite.png"
        }
    
        BoxCollider {
            id:collider
            width: 300
            height: 80
            x: -width/2
            y: -height/2
            fixedRotation: false
        }
    
        MovementAnimation {
            target: parent
            property: "pos"
    
            velocity: Qt.point(-200, 0)
    
            // start running from the beginning
            running: true
        }
    }

    Cheers, Alex

Viewing 2 posts - 1 through 2 (of 2 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Voted #1 for:

  • Easiest to learn
  • Most time saving
  • Best support

Develop Cross-Platform Apps and Games 50% Faster!

  • Voted the best supported, most time-saving and easiest to learn cross-platform development tool
  • Based on the Qt framework, with native performance and appearance on all platforms including iOS and Android
  • Offers a variety of plugins to monetize, analyze and engage users
FREE!
create apps
create games
cross platform
native performance
3rd party services
game network
multiplayer
level editor
easiest to learn
biggest time saving
best support