Need advice in several issues
Posted: Sun Jun 24, 2018 8:46 pm
Hi,
I'm trying to integrate physics to a jRPG and I'm having a hard time with NPCs because I have no real experience when it comes to physics integration. My main problem is that I have several NPC behaviours and I don't know what's the best approach physics-wise to implement. I've been playing and testing for some days but I need some tips.
Right now "player" is CharacterControllerInput from BEPUphysicsDemos.AlternateMovement slightly tweaked (changed input and camera funcs)
The possible NPC behaviours are:
a) NPCs moving by his own:
1 - Roaming NPC. Walks randomly. Can be pushed by player, cannot push player (but must not go through player)
2 - Path following NPC. Walks a predefined path. Can push player, cannot be pushed by player (but must not go through player)
3 - "Cutscene" NPC. Movement controlled by script. Must go through everything (in order to obey the script) while respecting terrain + stairs.
b) NPCs not moving by his own:
4 - Static NPC. Stays at a place. Unmovable by anything.
5 - "Physics" NPC. Obey physics laws.
6 - "Physics" NPC. Like 5 with locked axis (i.e. crates which can't rotate in the Y axis)
All NPCs should respect the terrain and go up/down stairs.
So far, I've done (or I know how to do):
* I've tagged all collidable/walkable-over objects with a group (A), and all NPCs with another group.
a) NPCs moving by his own:
1 - ??
2 - ??
3 - NPC is CharacterControllerInput. Disable collisions between NPC group, but allow all other collisions during cutscenes.
b) NPCs not moving by his own:
4 - Easy, a normal static bepu Entity, "no mass".
5 - Using Entity too (box, cylinder, convex hull) but with a mass.
6 - As 5, but with LocalInertiaTensorInverse. 0 to no rotation at all, no idea to lock Y rotation only but almost sure it can be achieved putting the correct values into LocalInertiaTensorInverse
And I think 1 and 2 can be achieved as CharacterControllerInput too, but handling collision events somehow. But I don't know if this (or any of
the 6 NPC types) are the easiest way to achieve it.
There's a final consideration which I don't know if this should go in a separate thread or if the consideration makes change some of the answers for some NPC types. CharacterCollider uses a Cylinder, but some NPC shapes should be something other than a Cylinder.
There are two reasons for that:
1-When approaching somebody to talk, cylinder against cylinder is pretty annoying because the player "slides" arround the NPC. When using a box instead (I'm using that in type 4 NPCs) the interaction is very natural.
2-Some NPCs are dogs or people mounting a moving horse. I could approximate a dog with a cylinder because it's small, but the horse is unlikely to give good results.
Sorry for the extensive post and thanks a lot for your time.
I'm trying to integrate physics to a jRPG and I'm having a hard time with NPCs because I have no real experience when it comes to physics integration. My main problem is that I have several NPC behaviours and I don't know what's the best approach physics-wise to implement. I've been playing and testing for some days but I need some tips.
Right now "player" is CharacterControllerInput from BEPUphysicsDemos.AlternateMovement slightly tweaked (changed input and camera funcs)
The possible NPC behaviours are:
a) NPCs moving by his own:
1 - Roaming NPC. Walks randomly. Can be pushed by player, cannot push player (but must not go through player)
2 - Path following NPC. Walks a predefined path. Can push player, cannot be pushed by player (but must not go through player)
3 - "Cutscene" NPC. Movement controlled by script. Must go through everything (in order to obey the script) while respecting terrain + stairs.
b) NPCs not moving by his own:
4 - Static NPC. Stays at a place. Unmovable by anything.
5 - "Physics" NPC. Obey physics laws.
6 - "Physics" NPC. Like 5 with locked axis (i.e. crates which can't rotate in the Y axis)
All NPCs should respect the terrain and go up/down stairs.
So far, I've done (or I know how to do):
* I've tagged all collidable/walkable-over objects with a group (A), and all NPCs with another group.
a) NPCs moving by his own:
1 - ??
2 - ??
3 - NPC is CharacterControllerInput. Disable collisions between NPC group, but allow all other collisions during cutscenes.
b) NPCs not moving by his own:
4 - Easy, a normal static bepu Entity, "no mass".
5 - Using Entity too (box, cylinder, convex hull) but with a mass.
6 - As 5, but with LocalInertiaTensorInverse. 0 to no rotation at all, no idea to lock Y rotation only but almost sure it can be achieved putting the correct values into LocalInertiaTensorInverse
And I think 1 and 2 can be achieved as CharacterControllerInput too, but handling collision events somehow. But I don't know if this (or any of
the 6 NPC types) are the easiest way to achieve it.
There's a final consideration which I don't know if this should go in a separate thread or if the consideration makes change some of the answers for some NPC types. CharacterCollider uses a Cylinder, but some NPC shapes should be something other than a Cylinder.
There are two reasons for that:
1-When approaching somebody to talk, cylinder against cylinder is pretty annoying because the player "slides" arround the NPC. When using a box instead (I'm using that in type 4 NPCs) the interaction is very natural.
2-Some NPCs are dogs or people mounting a moving horse. I could approximate a dog with a cylinder because it's small, but the horse is unlikely to give good results.
Sorry for the extensive post and thanks a lot for your time.