Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for spherecast #2094

Open
yaustar opened this issue May 23, 2020 · 9 comments · May be fixed by #5039
Open

Add support for spherecast #2094

yaustar opened this issue May 23, 2020 · 9 comments · May be fixed by #5039
Labels

Comments

@yaustar
Copy link
Contributor

yaustar commented May 23, 2020

From forum thread: https://forum.playcanvas.com/t/ability-to-use-spherecast/13310/3

It would be great to add some form of sphere casting if the current Ammo,js API allows it.

@yaustar yaustar added feature request area: physics Physics related issue labels May 23, 2020
@albertvanveen
Copy link

I would also like to see this feature in PlayCanvas because I could use it in different situations.

@donpdang
Copy link

Yes I would love this feature as well as it would prevent me from having multiple raycasts

@simonbq
Copy link

simonbq commented May 27, 2021

This would be a great feature as it would make it easier to improve click accuracy on mobile devices instead of raycasting.

@LeXXik
Copy link
Contributor

LeXXik commented May 27, 2021

@simonbq the Ammo version that PC currently only has partial support for it. I made an extension for convex shapes sweep tests. You can grab a later version of Ammo from there too, which enables full support.

https://forum.playcanvas.com/t/playcanvas-physics-extension/13737

@simonbq
Copy link

simonbq commented Jun 28, 2021

@LeXXik Cheers, I'll check it out. I'm mainly interested in it being added to the hosted version of PlayCanvas though.

@constlet
Copy link

constlet commented Jul 9, 2021

This will be useful for a camera collision system, it will make it smoother and not punch through certain size gaps.

@LeXXik
Copy link
Contributor

LeXXik commented Jul 9, 2021

@yaustar @willeastcott I could add a support for convex sweeptests, but the current Ammo version needs to be updated.

@willeastcott
Copy link
Contributor

@LeXXik What would the newly introduced PlayCanvas API be? I think it's fine if the ammo build needs to be updated. You'd just check for the necessary functions and if they're not there, just print a warning.

@LeXXik
Copy link
Contributor

LeXXik commented Jul 22, 2021

Well, we already have the following raycast methods on rigidbody component system:

app.systems.rigidbody.raycast(...);
app.systems.rigidbody.raycastAll(...);

I do think they belong under collision component system, though, as rigid bodies are shapeless and not able to collide. It is a collision component that gives body a shape, mass, and other properties that rays can detect. In fact, own physics system would be even better, which would handle casts in the physics world of the current backend, but that can be left for a better day. Nevertheless, we can add similar:

app.systems.rigidbody.shapeCast(...);

As with raycast it would take starting position and end position of the cast, as well as required shape that would be used for the sweep test. It can optionally take starting and final rotation quaternions of the shape.

Because the shape is an Ammo object, I did have convenience methods, like .sphereCast() or .boxCast(), etc, which would create the shape for the user and destroy it when finished. To simplify the API, we can add enums, like pc.SHAPECAST_SPHERE that shapeCast() method would take with optional params that describe it, like sphere shape radius, for example, etc.

I will make a draft PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants