Hi guys,
I’m using the MoveToPointHelper to move an object towards the player position, on the x-axis only. The y is handled elsewhere. My issue is that the outputXAxis property of the helper only ever outputs +1, so I’ve a feeling there’s some misuse on my end.
Here’s an example game that demonstrates the issues (use left/right keyboard arrow keys to move around):
import Felgo 3.0
import QtQuick 2.0
GameWindow {
id: gameWindow
activeScene: scene
screenWidth: 960
screenHeight: 640
EntityManager {
id: entityManager
// entities shall only be created in the gameScene
entityContainer: scene
}
Scene {
id: scene
// the "logical size" - the scene content is auto-scaled to match the GameWindow size
width: 480
height: 320
Keys.forwardTo: controller
PhysicsWorld {
debugDrawVisible: true
}
Rectangle {
color: "black"
anchors.fill: parent
}
EntityBase {
id: player
width: 25
height: 25
y: 200
x: scene.width/2 - player.width
TwoAxisController {
id: controller
}
Rectangle {
anchors.fill: parent
color: "red"
}
BoxCollider {
id: collider
bodyType: Body.Dynamic
linearVelocity: Qt.point(controller.xAxis * 1000, 0)
}
}
EntityBase {
id: enemy
width: 25
height: 25
x: 0
y: 50
Rectangle {
anchors.fill: parent
color: "white"
}
MoveToPointHelper {
id: moveToPointHelper
targetObject: player
onOutputXAxisChanged: console.debug("Move P Helper X:", outputXAxis)
}
MovementAnimation {
id: followAnimation
target: parent
property: "x"
velocity: 30 * moveToPointHelper.outputXAxis
running: true
}
}
}
}
You’ll see that the enemy entity only ever moves to the right.
Any ideas where the issue is