Jump to content
PerEspen00

Collision for characters

Recommended Posts

Is there any way to get add more collision for character controllers? Maybe create a box in the start function or something to make a bigger collision than the default cylinder(which really should get fixed).

 

So I'm looking for a piece of code to use in the start function of my creature script so that I can create a box which will act as that creatures collision box for sword hits and general physics collision in the game.

 

Any help appreciated!

Share this post


Link to post

There is no way to change shape of character controller collider. The only workaround is to use regular rigidbody instead of character controller, but that brings many disadvantages.

Share this post


Link to post

There are many ways to detect if a sword hits a creature. Since you're using Lua, the easiest is probably CollisionTrigger.

 

For general physics collisions, you could parent a box to a creature. Check out the code examples in the Entity docs, specifically SetShape and SetParent. However, the navigation system will ignore it so you might not get the effect you're hoping for.

Share this post


Link to post

For general physics collisions, you could parent a box to a creature. Check out the code examples in the Entity docs, specifically SetShape and SetParent. However, the navigation system will ignore it so you might not get the effect you're hoping for.

You can't attach collider as a child, this will break physics.

Share this post


Link to post

It won't work, unless Josh adds ability to change character collider, you will have to use rigid body for anything like this.

Share this post


Link to post

So there is no way to use navmesh if the character isn't a cylinder shaped thing? That should really get fixed... kind of a game breaker.

Share this post


Link to post

Yeah this big flaw plagues Unity engine as well, I think if Josh came up with a solution it'd be a nice leg up over Unity in that regard.

Share this post


Link to post

The problem is with recast/detour. The navmesh needs certain data like character height/width/stepheight to determine if a path would be feasible, how close a path should be around walls, etc... If you had multiple character sizes then you would need multiple navmeshes - which means characters on different navmeshes would have no knowledge of each other. While I agree that having access to certain variables to control the character cylinder size would be ideal, then it would be an issue with navmeshes and what is passed to it prior to creation. The easiest solution (especially for 90% of users) was to hardcode this. Maybe one day Josh will allow us to control these variables for the controller and the navmeshes, but I would be surprised since this has been requested since LE3 with no luck.

Share this post


Link to post

Ok, I understand the problem. How about a way to check if a sword has hit a target? Could one create something in front of the player which checks for collision?

Share this post


Link to post

The melee script uses a raycast. Box raycasting is used on the character to collide with his arms, legs, head, etc. This is in the monster and soldier AI scripts.

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...