Hi Guys,
I’m having a problem with Box Collider.
Issue 1.
Full display of problem is shown on this YouTube link: Video showing problem
I create an entity with a BoxCollider:
BoxCollider {
id: collider
width: image.width * .75
height: image.height * .75
anchors.centerIn: staticObject
bodyType: Body.Static
categories: ColliderCategories.solidBackgroundObject
}
When I create my entity without specifying a rotation, it works fine and the BoxCollider is centred in it.
When I rotate my entity dynamically (by using the spin entity arrows I implemented into my level editor) – it still works fine and the BoxCollider rotates with the entity.
PROBLEM: When I create my entity and specify a rotation then the BoxCollider is offset from the entity. The BoxCollider is in the correct rotation, but is offset.
My PhysicsWorld and my EntityManager are both in the same container:
Item{
id: container
transform: Rotation { origin.x: camera.zoom * (playerTank.x + playerTank.width/2); origin.y: camera.zoom * (playerTank.y + playerTank.height/2) ; angle: container.rotateAngle;}
property real rotateAngle: (rotationFree) ? 0 : -playerTank.rotation-90
EntityManager {
id: entityManager
entityContainer: container
// required for LevelEditor, so the entities can be created by entityType
poolingEnabled: true
dynamicCreationEntityList: [ Qt.resolvedUrl("../entities/Background.qml"),
Qt.resolvedUrl("../entities/TankTrack.qml"),Qt.resolvedUrl("../entities/Tree.qml"),
Qt.resolvedUrl("../entities/BaddyTank.qml"),Qt.resolvedUrl("../entities/Tank.qml"),
Qt.resolvedUrl("../entities/TankBullet.qml"),Qt.resolvedUrl("../entities/Target.qml"),
Qt.resolvedUrl("../entities/Waypoint.qml"),Qt.resolvedUrl("../entities/MuzzleFlash.qml"),
Qt.resolvedUrl("../entities/DamageSmokeParticle.qml"),Qt.resolvedUrl("../entities/ExhaustParticle.qml"),
Qt.resolvedUrl("../entities/SpawnPoint.qml"),Qt.resolvedUrl("../entities/Scenery.qml"),
Qt.resolvedUrl("../entities/BaddyTankLight.qml"),Qt.resolvedUrl("../entities/Turret.qml"),
Qt.resolvedUrl("../entities/ImageOnly.qml"),Qt.resolvedUrl("../entities/StaticObject.qml"),
Qt.resolvedUrl("../entities/EntitySupervisor.qml")]
}
BackgroundEdges{/*Outside edges of water around background entities*/}
// use a physics world because we need collision detection
PhysicsWorld {
id: world
updatesPerSecondForPhysics: 60
debugDrawVisible : true
}
}//Container
Issue 2:
I have a BoxCollider within an entity that is only for collision detection and not for physics movement. When I rotate the entity, the BoxCollider offsets itself.
collisionTestingOnlyMode is set to true.
If I change collisionTestingOnlyMode to false, then the BoxCollider centres perfectly. However I want it to only be for collision testing.
How do I keep the BoxCollider centred and stay in collisionTestingMode?