- Home /
Interactable vines in 2d platformer
Greetings!
I'm making interactable vines in a 2d platformer. I'm using a skinned mesh renderer and a push rigidbody to move the vines around.
However, I'm not satisfied with my results, I want the vines to "hang" on the character instead of him pushing them around. My current solution uses multiple joints where each joint has a capsule collider attached that the character controller pushes around, but at some points the vines are pushing the character around too. Is there any way to get them to behave more like cloth?
The push script
#pragma strict
var pushPower = 2.0;
function OnControllerColliderHit (hit : ControllerColliderHit)
{
var body : Rigidbody = hit.collider.attachedRigidbody;
// no rigidbody
if (body == null || body.isKinematic) { return; }
// We dont want to push objects below us
if (hit.moveDirection.y < -0.3) { return; }
// Calculate push direction from move direction,
// we only push objects to the sides never up and down
var pushDir = Vector3 (hit.moveDirection.x, 0, hit.moveDirection.z);
// If you know how fast your character is trying to move,
// then you can also multiply the push velocity by that.
// Apply the push
body.velocity = pushDir * pushPower;
}
http://imageshack.us/f/36/hinge.png/ My current settings
Thanks in advance!
Your answer
Follow this Question
Related Questions
Rope simulation 1 Answer
Joints 2D, rope 0 Answers
Distribute distances between configurable joint links 0 Answers
Why do my rope behave strange? Stretching rope problem. 0 Answers
Rope Physics using Spring Joints 3 Answers