Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by Symbie · Sep 27, 2020 at 12:13 PM · movementrigidbodyragdoll

Replace player with ragdoll

Im making a game where the player swings around like spider man. at the moment the player is just a capsule. i want to replace the capsule with a new ragdoll i made. the ragdoll works great and flops around properly but replacing the capsule with the ragdoll doesnt work and the game isnt playable. im not sure what to do to fix this or what i need to add/remove. the scripts i have are a script to let the player swing around, and a script that points the player in the direction of what they are swinging on. these are the scriipts:

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class GrapplingGun : MonoBehaviour
 {
     LineRenderer lr;
     Vector3 grapplePoint;
     public LayerMask whatisGrappleable;
     public Transform gunTip, cameraPos, player;
     float maxDistance = 200f;
     private SpringJoint joint;
 
     public static bool stopGrappleBool;
 
     private void Awake()
     {
         lr = GetComponent<LineRenderer>();
 
         StopGrapple();
     }
 
     private void Update()
     {
         if (Input.GetMouseButtonDown(0))
         {
             StartGrapple();
         }
         else if (Input.GetMouseButtonUp(0))
         {
             stopGrappleBool = true;
         }
 
         if (stopGrappleBool)
         {
             StopGrapple();
         }
     }
 
     private void LateUpdate()
     {
         DrawRope();
     }
 
     void StartGrapple()
     {
         RaycastHit hit;
         if (Physics.Raycast(cameraPos.position, cameraPos.forward, out hit, maxDistance, whatisGrappleable))
         {
             grapplePoint = hit.point;
             joint = player.gameObject.AddComponent<SpringJoint>();
             joint.autoConfigureConnectedAnchor = false;
             joint.connectedAnchor = grapplePoint;
 
             float distanceFromPoint = Vector3.Distance(player.position, grapplePoint);
 
             joint.maxDistance = distanceFromPoint * 0.2f;
             joint.minDistance = distanceFromPoint * 0.05f;
 
             joint.spring = 10f;
             joint.damper = 25f;
             joint.massScale = 2f;
 
             lr.positionCount = 2;
         }
     }
 
     public void StopGrapple()
     {
         lr.positionCount = 0;
         Destroy(joint);
 
         stopGrappleBool = false;
     }
 
     void DrawRope()
     {
         if (!joint) return;
         lr.SetPosition(0, gunTip.position);
         lr.SetPosition(1, grapplePoint);
     }
 
     public bool IsGrappling()
     {
         return joint != null;
     }
 
     public Vector3 GetGrapplePoint()
     {
         return grapplePoint;
     }
 }

and the second:

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class RotatePlayer : MonoBehaviour
 {
     public GrapplingGun grappling;
 
     private Quaternion desiredRotation;
     private float rotationSpeed = 5f;
 
     private void Update()
     {
         if (!grappling.IsGrappling())
         {
             desiredRotation = transform.parent.rotation;
         }
         else
         {
             desiredRotation = Quaternion.LookRotation(grappling.GetGrapplePoint() - transform.position);
         }
 
         transform.rotation = Quaternion.Lerp(transform.rotation, desiredRotation, Time.deltaTime * rotationSpeed);
     }
 }

any help would be appreciated

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image SlowCircuit · Sep 28, 2020 at 12:03 AM 0
Share

Are you trying to use the ragdoll only when swinging?

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

240 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How can I move a rigidbody ragdoll without velocity? 0 Answers

Calling Rigidbody.MovePosition, no movement at all 4 Answers

rigidbody simulation collision check frequency check control?? 0 Answers

Issues Making Character Move With Rigidbody 1 Answer

Buggy Collision 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges