Collision Filtering Pt.2

Alright, so we have collision filtering (yay \o/) but there’s still one thing I believe people want.

Disallowing certain objects to affect physics on another part, but allowing the certain object to collide with the other part.

Usecase1: If you created a box, (that you can stand inside,) put it on water, then start pushing, the box will move. This realistically doesn’t make sense. I don’t want the player to be able to push the box on the water while he’s in the box. (Of course, in some cases you do, which is why this is an optional thing.)

Usecase2: Lets say i’m incontrol of a flying plane. The plane is using bodyvelocity to move. Lets say some player then jumps out of his chair. When that happens, he will collide with some part of the ship. In my cases, the player will actually affect the whole plane, which doesn’t make sense. To fix this, I want the plane to ignore players (and npcs in that matter) but still allow them to collide with the plane.

Another way to explain it: If I had a part with a bodyposition inside of it and where to jump on it, it would go all crazy (starts turning, flipping me off.) If I were to enable this feature with this part and myself, I wouldn’t change the state of the part, but I would be able to walk on it.

Note: I presented the idea in the form of adding something to collision filtering, but this update could actually be a good physics update. However, it might affect some games, which is why it should be optional.

EDIT: Another way of putting it: “One-way collision.” (see this post below)

34 Likes

This could be useful for preventing other players from pushing you off cliffs

3 Likes

I thought you could do this already with CollisionGroupSetCollidable? Unless I’m misunderstanding what you’re saying.

Are you asking for collision groups that are 1 way?

Example: You have Group A (Truck) and Group B (Players)
You want Players to collide with the Truck and be pushed by the Truck, but you don’t want the Truck to collide with Players, that is, you don’t want Players able to push the Truck.
So you call something like:

 CollisionGroupSetCollidableOneWay (A,B,false)

to negate Player’s physics on the Truck, that is, negate Group A from colliding with Group B, But Group B still collides with Group A.

If that is the case I fully support.

11 Likes

That would be awesome! I fully support.
It could fix the bounce off the player if we hit him driving a car.

3 Likes

Wait, how is that logically possible? How can A collide with B, while B isn’t colliding with A? The very definition of a collision implies that both parties are colliding with each other. Am I misunderstanding something?

4 Likes

Yes, one way collision. That’s actually a nice way of putting it…

@Crazyman32

The feature here doesn’t stop collision, it stops the effects of collision, but one way.

1 Like

I think I understand the idea here. It’s like the train in GTA V. You collide with it, and it collides with you, but it is not at all affected by you. Just like any other objects, you and the train cannot be in the same place, but if one of the two has to move, it will never be the train.

In that sense, ‘collision’ is the wrong word here, I think.

It’s as if the train, or truck or plane or whatever, were anchored and had its own physics programmed for it that ignores player characters and small props, but not scenery or other vehicles.


I think this is a neat and totally reasonable idea, it just needs better terms to describe it.

ComparativelyAnchored? PhysicallyAffected? ReactionPriority?

I don’t really know. There’s probably a technical name for this sort of stuff, but I’m not even sure what to search up to find it.

15 Likes

Kinematic is the term that other engines use. This usually means a body that has collision but is not controlled by physics; basically the same as an Anchored part that you’re using CFrame to move around. Probably not what you want.

I think @Khanovich might have some insight into this for you though. He seems to have studied GTA 5’s physics quite a bit.

3 Likes

One question I would have is what is the mass ratio between the colliding bodies you are using? I imagine most Roblox trains are not built to have much more density than an NPC model. What happens if more realistic ratios are used? In theory, a train hitting an NPC (without humanoid force shenanigans of course) should plow right through with negligible effect.

4 Likes

So you want to simulate infinite mass for a single object in specific two body collisions? Seems quite possible. I think it would be quite easy to implement from what I know of from what I made here.

Realistic density is nice for physics simulations, but it’s painful to micromanage the density of inherently unrealistic objects so they behave somewhat as intended. I think predictable, controllable behavior is more important for actual games.

4 Likes

I tested this in a networked environment and the result is comical to say the least, and aggravating in normal play.

The test environment:

The train:

Speed - 200 studs per second
Mass - 920396 mass units

The driver:

gulp78, a player I roped into helping me test

The target:

SparklyBlueNinja, another player I roped into helping me test

The result:

https://gfycat.com/SlimRepulsiveBactrian

In normal play, e.g. walking in a moving train car, the character’s tweening is not enough to keep the train from derailing when it crashes into the lagging character, regardless of the mass of the train. This is a big issue for train games because it means game creators have to lock down characters and severely punish people who get up in or even approach moving trains.

In Play Solo, where the train and character are on the same computer, the train pushes aside the character quite handily, even without such a huge mass. Currently this isn’t relevant in online play because of roblox’s netcode.

14 Likes

Thanks for testing and providing the video. Hopefully they will stop making the humanoid so op.

Now, here’s the interesting thing: thanks to FilteringEnabled and NetworkOwnership, the requested feature can almost be achieved.

There’s some caveats, though:

  • The train’s network ownership must be assigned to a client, the server is right out
  • Character CanCollide of all other characters must be set at minimum by the owner client every Stepped

I have published the LocalScript here:

With the script installed, the interaction between the train and the characters in the networked environment resembles the interaction in Play Solo:

https://gfycat.com/IncredibleDentalIbizanhound

(the lagging effect can be seen in the video where SparklyBlueNinja is not pushed at the same time as I am. If he was standing in a moving train, the walls of the train would crash into him)

There’s some unfortunate limitations due to the caveats above:

  • Characters cannot interact with physics items networked to other clients (e.g. soccer balls)
  • Trains that are networked to the server can be derailed in the same manner as without the script
    • This is because the server cannot set the cancollide of characters
      • The server could set the cancollide of characters, but then everyone would wallhack then fall through the baseplate
        • Alright so I haven’t tested the above, but I’m pretty sure that’s what would happen (as well as cause a lot of latency due to property replication)
      • If setting the collision of characters did work for the server as it does for the client, there’s zero selectivity: characters cannot interact with any physics item on the server

So here’s a use case for this feature:

Trains networked to the server do not crash due to character interference

  • Characters interfering with the right-of-way (as seen in the videos posted)
  • Characters standing on or in moving trains
  • Characters walking on top of miniature trains (small objects underneath characters are often flung)
  • Characters walking into and jumping under idle trains (will often derail them)

I’ve abstained from making autonomous trains specifically for this reason.

7 Likes

Normally, when two objects collide, an equal force is put on both objects, but what I think he’s saying is that part1 would hit part2, and part2 would react to the hit from part1, but part1 would keep moving as if it didn’t hit part2. I’m not sure this is what he’s saying, but it could also be based on which object causes a disturbance on another part. Ex: if the plane causes the player to move, the player will go through the plane as if cancollide = false, but if the player causes a force on the plane by pushing it or something, the game will realize the player caused the influence on the plane, so it’ll let the parts collide like normal.

Support!

There are many times where I would like to use a body mover to set an object into motion, and then have that object’s motion be unaffected by collisions with players.

Maybe add something analogous to a CollisionGroup, but for physics interactions.

1 Like

I’d personally rather see something to do with helping out the server translate fast moving objects to the client better, when the fast moving objects are controlled by other clients.

i.e.
Stop the “Vision-Lag” that people with cars see all the time.