简体   繁体   中英

How to create your own Raycast component, which doesn't need colliders, but supports Skinned Mesh Renderer in C# Unity3D?

I am making a First Person Shooter and I have a player model(3D), rigged, with animations and a Skinned Mesh Render component on it. I tried the Mesh Collider component, but it has a large negative impact on the game performance (animations, frames per second). So I thought, there must be a way to make your own Raycast System(Script, Variable), but I don't know where to start. Is there a way to look into the RaycastHit component script of Unity or do you guys have any ideas how to start making an own Raycasting Script, which doesn't need collider, but supports the Skinned Mesh Renderer component?

PS I need it for shooting at players.

Hello I am sorry for my dumb question xD. Almost 3 years later I saw this question again, so I have decided to close it now with the following 'answer':

Don't use a mesh collider on a mesh that is dynamically controlled by bones (a rigged mesh). This is just too heavy for most computers. I recommend to use multiple capsule colliders for the limbs and head, and use 1 or 2 box colliders for the chest/stomach. Attach these colliders to the bones so the colliders will move along with the animations. In this way you can use the default raycast system of unity: Physics.Raycast .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM