Hello,
I've been experimenting with replacing the player movement system in GZDoom for a while. My latest idea is to treat every kind of movement as a "movement state". Each movement state is a class and comes with two methods: "CheckConditions" to see if the player is in the movement state, and "MovePlayer" to actually process movement on the player.
There's a base movement state class that is abstract, and from there I would imagine "NoclipMoveState", "WaterMoveState", "GroundMoveState", and "AirMoveState". In the future, if I need to add a new MoveState, it would be as simple as making a new subclass of the base movement state and somehow referencing it in an array.
I've been able to get this system working by using a static array to hold all of the classes and the initialize an private array of instances - one instance for each MoveState. The problem I have is that this would be wasteful in the scenario that there are multiple players. I only really need to create a single global registry of all possible move states and make it available for reference/implementation in my PlayerPawn derivatives.
My current idea is that the player class should be responsible for iterating through the movement states and running its methods. The best candidate for implementation I can imagine is with a StaticEventHandler subclass to manage these movement states, but I've seen warnings about their usage in regards to networking, and I'm not well-versed enough to know if what I'm doing is a problem.
Sorry for not providing any code - I'm speaking more in a conceptual sense.
Trying to figure out how to implement a global array of "movement states"
Moderator: GZDoom Developers
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
-
- Posts: 1
- Joined: Wed Oct 12, 2022 9:37 pm
- Preferred Pronouns: He/Him
- Operating System Version (Optional): EndeavourOS
- Graphics Processor: nVidia with Vulkan support
-
-
- Posts: 1651
- Joined: Wed May 13, 2009 3:15 am
- Graphics Processor: nVidia with Vulkan support
Re: Trying to figure out how to implement a global array of "movement states"
It depends on what exactly you want to do with your array and/or its items.wauterboi wrote: ↑Sat Dec 10, 2022 1:38 amThe best candidate for implementation I can imagine is with a StaticEventHandler subclass to manage these movement states, but I've seen warnings about their usage in regards to networking, and I'm not well-versed enough to know if what I'm doing is a problem.
Think of it like this: each player gets their own copy of the event handler. Now, consider the following possibilities:
- Can the number and/or the order of items in the array change?
- Do the items in the array have some sort of state (e.g. non-local variables) that can affect their behavior?
Code: Select all
Array<MyClass>[MAXPLAYERS] MyArray;