Skip to content

Conversation

@Mambouna
Copy link

@Mambouna Mambouna commented Mar 31, 2025

Adds the following functions to actor.py allowing for easier movement when actors are rotating:

  • move_towards_angle(angle, distance) : Base function of this PR. All other functions use this.
  • move_towards_point(point, distance, overshoot=False) : Simply calls angle_to(point) and then uses move_towards_angle(). By default, the actor stops at the target point if the given distance was greater. This can be changed by giving a third parameter overshoot as True, which disables the convenience check.
  • move_forward(distance) : Moves in the direction the actor is facing.
  • move_backward(distance) : Moves in the opposite direction of the one the actor is facing.
  • move_left(distance) : Moves left in relation to the facing of the actor. I am conflicted an the name right now. Another option could be strafe_left() but then there is no consistency with the other functions.
  • move_right(distance) : Analog to move_left().

Fixes #193.

@lordmauve lordmauve added the actor Issues/PRs involving Actor objects label Apr 14, 2025
@Mambouna
Copy link
Author

@lordmauve Any thoughts on this?

Mambouna added 6 commits June 22, 2025 12:56
Adds the following functions to move actors:
- move_towards_angle(angle, distance) : Moves the actor towards the given angle by the given amount.
- move_towards_point(point, distance) : Convenience function that just runs angle_to(point), followed by move_towards_angle(angle, distance).
- move_forward(distance) : Moves the actor along its angle by the given distance.
- move_backward(distance) : Moves the actor in the opposite direction of its angle by the given distance.
- move_left(distance) : Moves the actor left based on its angle by the given distance.
- move_right(distance) : Moves the actor right based on its angle by the given distance.
Former approach was broken due to not rememberin math and python
right while not having internet...

Now, the movement functions behave properly.

One major bug is left before this can be pulled. When running
move_towards_point() every update, it results in a jittering
back and forth which is not expected until the actor overshoots
the target point. Instead it happens every single frame.
The previously mentioned bug was not part of the new functionality but
caused by a typo in the testing project. From current observation,
move_towards_point() works correctly.

Unless relevant reworks are necessary, the functionality for this PR is
now done.
Added an optional parameter to `move_towards_point()` named
`overshoot` that is `False` by default. Actors will now
automatically come to stop at the target when moving towards
a point (preventing the rapid back and forth from before)
unless `overshoot` is supplied as `True`.

Updated documentation to reflect this change.
@Mambouna Mambouna force-pushed the actor_angle_movement branch from 551877a to 405728e Compare June 22, 2025 10:59
@Mambouna
Copy link
Author

As with the mouse PR, I added unit tests for all new functionality, which I hope are good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

actor Issues/PRs involving Actor objects

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow Actors to move forwards an amount according to their angle

2 participants