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

Add getGlobalOldPos() helper to Actors #2922

Closed
mattjennings opened this issue Feb 3, 2024 · 2 comments · Fixed by #3017
Closed

Add getGlobalOldPos() helper to Actors #2922

mattjennings opened this issue Feb 3, 2024 · 2 comments · Fixed by #3017
Labels
enhancement Label applied to enhancements or improvements to existing features stale This issue or PR has not had any activity recently

Comments

@mattjennings
Copy link
Contributor

Context

Serves same purpose as this.oldPos, but for the global position.

Proposal

Add this.getGlobalOldPos() method to Actor.

Additional thought: any appetite for turning getGlobalPos() into a getter?

class Actor {
  get globalPos(): ex.Vector {
    // do global pos logic
   }

  get globalOldPos(): ex.Vector {
     // .. etc
  }
}
@eonarheim
Copy link
Member

@mattjennings 100% totally agree.

I'm down to explore the getter 👍

@eonarheim eonarheim added the enhancement Label applied to enhancements or improvements to existing features label Feb 4, 2024
Copy link

github-actions bot commented Apr 5, 2024

This issue hasn't had any recent activity lately and is being marked as stale automatically.

@github-actions github-actions bot added the stale This issue or PR has not had any activity recently label Apr 5, 2024
eonarheim pushed a commit that referenced this issue Apr 25, 2024
…balPos getter (#3017)


Closes #2922

## Changes:

- `actor.oldGlobalPos` returns the globalPosition from the previous frame
- `actor.getGlobalPos()` - use `actor.globalPos` instead
- `actor.getGlobalRotation()` - use `actor.globalRotation` instead
- `actor.getGlobalScale()` - use `actor.globalScale` instead

This required some changes to `MotionSystem` so that `globalPos` could be properly captured. Previously, the parent's transform may have already been updated in the system's update when processing a child entity, leading to an incorrect `oldGlobalPos` value. Now, the MotionSystem update captures the entity & all of its children at the same time, skipping any entities that have parents as to not capture them twice over.

This also deprecates other `getGlobalXYZ()` functions and replaces them with getters for consistency.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Label applied to enhancements or improvements to existing features stale This issue or PR has not had any activity recently
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants