• 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
0
Question by smillyfaces · 6 days ago · rigidbodyspringjoint

Grapple Gun Parkour

So before I begin I just want to say thank you for trying to understand and help with with this problem, I know it's very particular.

So far I have a system that utilizes a spring joint and a line renderer that allows your to swing on any position of choice. I also have a system that will propel that player towards the grapple point (b spring joint), utilizing this function:

 void reel()
     {
         if (IsGrappling())
         {
             if (Vector3.Distance(player.position, grapplePoint) > minReelDis)
             {
                 Vector3 normalized = (grapplePoint - player.position).normalized;
                 rb.velocity = Vector3.MoveTowards(rb.velocity, normalized * reelSpeed, 1.0f);
             }
             else
             {
                 rb.velocity = Vector3.zero;
             }
         }
     }

The problem is that when you have any momentum that offsets the player while moving towards the grapple point, such as swaying in the air, it will overshoot the grapple point. I only want this to happen based on which of the WASD the player is pressing, kind of like swinging your body in the direction you want to move, otherwise, I want the player to move directly towards the grapple point.

Here is an example of what i want my movement to look like from a fan game on AoT I found:

Video of movement.

if can post or upload any of my scripts if needed. One more thing, I'm using two grapple guns with one either side of the player that you can control independently.

Comment
Add comment · Show 3
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 unity_ek98vnTRplGj8Q · 5 days ago 0
Share

Looks like your links are broken, can you try to repost so I have a better idea what you are looking for?

As far as fixing your problem, it looks like you are on the right track to me. The next thing I would try in this situation is try to scale your velocity correction by how close you are to your grapple point. In other words, when you are far from the grapple point it should work as it does now, but as you reel in it starts steering your velocity more rigidly.

Something like

   //Play with these values 
  public float minGrappleDistance;
  public float maxGrappleDistance;
  public float minGrappleRigidity;
  public float maxGrappleRigidity;
  
  void reel()
      {
          if (IsGrappling())
          {
              float distanceToGP = Vector3.Distance(player.position, grapplePoint);
              if (distanceToGP > minReelDis)
              {
                  //if you are at maxGrappleDistance or beyond, you will have minGrappleRigidity
                  //as you approach minGrappleDistance you will become more rigid, up to maxGrappleRigidity
                  float normalizedDistance = (distanceToGP - minGrappleDistance) / (maxGrappleDistance - minGrappleDistance);
                  normalizedDistance = 1f - Mathf.Clamp(normalizedDistance, 0f ,1f);
                  float grappleRigidity = minGrappleRigidity + (normalizedDistance * (maxGrappleRigidity - minGrappleRigidity));
 
                  Vector3 normalized = (grapplePoint - player.position).normalized;
                  rb.velocity = Vector3.MoveTowards(rb.velocity, normalized * reelSpeed, grappleRigidity);
              }
              else
              {
                  rb.velocity = Vector3.zero;
              }
          }
      }
avatar image smillyfaces · 4 days ago 0
Share

@unity_ek98vnTRplGj8Q Actually, here's a video from the game I referenced: Video of movement. Otherwise this helped a lot, now the player will no longer overshoot, but I still cant control the direction of my movement. Is there any way I can influence the direction of my movement while grappling, such as changing the minDistance based on what direction your moving, ect. Also, not entirely important, but is there any way to make accelerate instead of having constant velocity?

avatar image unity_ek98vnTRplGj8Q smillyfaces · 4 days ago 0
Share

You can always just add any movement vector to your velocity vector to give some character control during grappling. Being able to replicate the video exactly will take a lot of experimenting, but likely what you will need to do is calculate your velocity value from your grapple first. If you want to accelerate then you can ramp this velocity value up over time after you first grapple on to something. Then, you can calculate an additional velocity value based on any movement keys that are being pressed and add them together.

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

161 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

Related Questions

VR Grapple hooks 0 Answers

What would it take to make a script that creates a spring joint that could drag rigidbodies, for example in Dani's karlson dev log 2 Answers

Make locomotive Pull Carriage 0 Answers

What would It take to Make a Script the Uses a Springjoint to drag a rigidbody say of a certain tag or layerMask? 0 Answers

Rigidbodies touching but OnCollisionStay stops being called 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