I’m creating a combat system for my game, and Roblox’s default character collisions won’t suffice since the players are always bumping into each other. Something similar to Minecraft’s collision system between players and NPCs would work perfectly, however. I’d essentially want it to work in the exact same way, except that instead of the still entity being pushed, the moving entity is pushed back or out in a natural direction. I’ve already put my StarterCharacter’s limbs into a collision group that’ll prevent players from colliding with other players’ characters, but I’m not exactly sure where to go from there. I suspect that the move is to use raycasts to detect if the player’s HRP is touching another and then use a BodyMover to push it out, and I assume it’d probably make sense only to cast these rays upon player input. but I’m not sure what exactly the specifics or the math would look like. If someone could provide some help I’d greatly appreciate it.
I’m creating a combat system for my game, and Roblox’s default character collisions won’t suffice since the players are always bumping into each other. Something similar to Minecraft’s collision system between players and NPCs would work perfectly, however. I’d essentially want it to work in the exact same way, except that instead of the still entity being pushed, the moving entity is pushed back or out in a natural direction. I’ve already put my StarterCharacter’s limbs into a collision group that’ll prevent players from colliding with other players’ characters, but I’m not exactly sure where to go from there. I suspect that the move is to use raycasts to detect if the player’s HRP is touching another and then use a BodyMover to push it out, and I assume it’d probably make sense only to cast these rays upon player input. but I’m not sure what exactly the specifics or the math would look like. If someone could provide some help I’d greatly appreciate it.
Minecraft uses a hitbox system, roblox uses physics collisions. The best way I could think of doing this is by applying a force when something gets pushed.
You would have to turn of collisions somehow so that you don’t get the collisions you don’t want.
You can use the event .Touched and connect it to a function which applies the force.
Nice Idea. Even though i would add a Magnitude function after the Touch so its not like that it gets pushed after the first renderstep.
Yes something like a timer. I imagine this would be very simple. There are scripts that you can use to turn of player collisions. (I’m not sure if this will interfere with the Touched event, doubt it will)
Probably not since it also works with CanCollide set to false parts
As I mentioned in the original post, I did put the StarterCharacter’s body parts into a collision group that would prevent them from colliding with each other, which means player collisions are turned off. I typically like to opt for raycasts instead of .Touched for accuracy, though I guess since this isn’t anything that needs to be extremely precise .Touched might work fine. Also, right, I mentioned that a BodyMover would probably be ideal. The problem that I’m having is trying to think of the appropriate math that will 1) move the character in a direction that feels natural and 2) apply the movement in a way that feels smooth and not overwhelming.