.Touched event returns object AND position

As a Roblox Developer, it’s very hard to do various physics based things that rely on .Touched events.

if I want to say, have particals appear where objects make contact, or know if you’re hitting on object with the pointy end of a crowbar (like in my VR game) my best option is a lot of math, that isn’t always the most reliable.

you could also compare the direction of the touch with the direction of velocity to calculate whether or not something is impacting square on, or scrapping across it.

the physics engine already knows the impact location, so why not just pass that information onto us with .touched?

34 Likes

The issue is that collisions are surface intersections, which are lines. This means that the way you formulated your request, the result would be a mean. Imagine you have 2 100x100 surfaces touching each other and someone wants to know how they’re touching, not just where. They wouldn’t be able to since the only information is a point somewhere between those surfaces. This would only make this useful for small collisions.

A better solution would be a class that holds information about the touch, allowing developers to use different methods to find the total intersection surface, the mean you are asking for and the normals.

4 Likes

well, that is tricky. but you can work with whatever it gives you with a bit of elbow grease.

You can use that position is a ray direction, whitelist raycasting to get the impact normal.

or… just have the .touched function return impact normal?

You could, but every non convex mesh is composed of multiple convex surfaces, so sometimes it can be more than one collision between 2 meshes. This means that it’d have to parse multiple tables per hit (array with positions, normals and surface size), which is a bit too much given how many collisions may happen each frame.

2 Likes

what if the second parameter returned a table with positions like this? :thinking:

or just have a function like “:GetTouchPositions(OverlapParams)”

Hello, Studio has an existing debug view that allows you to view touching BasePart positions that looks to be exactly what GregTame is looking for.

We would just need a way to get the data that the preview is using inside our own scripts.

The request is about getting collision information in games, not for debugging. These tools probably use very expensive calls that don’t matter in Studio, but would be useless in-game.

wow how mean for roblox to not let us get this in game by code

Not nearly useless but maybe expensive. There is no information out there on this stuff though.