Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

forgotten changes with the second fix to issue #80 #85

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion gdx-ai/src/com/badlogic/gdx/ai/steer/behaviors/Wander.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ public class Wander<T extends Vector<T>> extends Face<T> {

/** The current orientation of the wander target */
protected float wanderOrientation;
/** the timepiece of the wander */
protected Timepiece timepiece = GdxAI.getTimepiece();

/** The flag indicating whether to use {@link Face} behavior or not. This should be set to {@code true} when independent facing
* is used. */
Expand All @@ -93,11 +95,17 @@ public Wander (Steerable<T> owner) {
this.internalTargetPosition = newVector(owner);
this.wanderCenter = newVector(owner);
}
public Wander (Steerable<T> owner, Timepiece tpiece) {
super(owner);
this.timepiece = tpiece;
this.internalTargetPosition = newVector(owner);
this.wanderCenter = newVector(owner);
}

@Override
protected SteeringAcceleration<T> calculateRealSteering (SteeringAcceleration<T> steering) {
// Update the wander orientation
float now = GdxAI.getTimepiece().getTime();
float now = timepiece.getTime();
if (lastTime > 0) {
float delta = now - lastTime;
wanderOrientation += MathUtils.randomTriangular(wanderRate * delta);
Expand Down