Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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
0
Question by Blakingale · Sep 13, 2021 at 10:24 AM · movementdistanceweapon

Keeping weapon at the back of character at certain distance

Hello, I currently am using multi-parent constraint to make the weapon in my character's hand to go back of my character. This is working perfectly fine. But when I move, the weapon goes through my character. So what I am trying to do is to keep the weapon at back of character not go through my character. What I want to achieve is much like how the weapon follows the player like in "Genshin Impact". I have tried adding multi-rotation/position constraint but they didn't help at all. I also have tried making an empty gameobject and attaching a script that had a simple follow and lookAt player but still couldn't achieve what I wanted. So I am looking for some other ways I can achieve this. Thanks in advance.

Comment
Add comment · Show 2
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 tyruji · Sep 13, 2021 at 12:40 PM 0
Share

not sure what you want to achieve, maybe you can send a reference video of what you have in $$anonymous$$d ?

avatar image Blakingale tyruji · Sep 14, 2021 at 01:04 PM 0
Share

i have uploaded a video in the other reply

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by DivainUnity · Sep 13, 2021 at 06:12 PM

Didn't quite get the problem. Does the weapon stays in place? Does the weapon walks with your character? If you're saying that the weapon is "attaching" to the back of your character as expected, I'm guessing the weapon "moves" strangely with your character, which can be caused by your weapon's place pivot gameObject being a child of your character's rig. Put your weapon's place pivot gameObject outside of the rig and that should do the trick.

Comment
Add comment · Show 5 · Share
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 Blakingale · Sep 14, 2021 at 01:02 PM 0
Share

What I want to achieve: https://youtu.be/AgC2JLuG62U?t=137

but what happens in my game: https://streamable.com/2w75mu

avatar image Blakingale Blakingale · Sep 14, 2021 at 01:12 PM 0
Share

to give more details this is how the hierarchy looks and the inspector.

https://prnt.sc/1s61vp7 https://prnt.sc/1s61xja https://prnt.sc/1s61u3q

in the script I just change the source object weight to make it appear at back of character. if I put the "weaponOnBack" outside of character's rig then the weapon doesn't rotate and that "going through character" still happens.

p.s.: in the screenshot, both multi-rotation and position are 0/off.

avatar image DivainUnity Blakingale · Sep 14, 2021 at 01:58 PM 1
Share

As I said, your weapon should be placed outside of your rig hierarchy so it won't be affected by the position and orientation, See Multi-Parent Constraint. Rather than adding the weapon directly as a child to the pivot gameobject, create a proxy gameobject outside of your character's rig hierarchy, add the multi-parent constraint component to it and constrain itself. The source object should be your weapon pivot and as you had, turn off the Maintain Offset. It should work Edit: forgot to mention that your weapon should be a child of the new constrained gameobject we've just created

Show more comments

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

186 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

Related Questions

Calling Other Variables from Other Scripts. 3 Answers

Gameobject stops moving and weird print statement response 0 Answers

Scripting: If velocity goes up, do this... 1 Answer

Why is move distance is different for character controller? 0 Answers

How can I cause a sphere to bounce forward infinitely with the same distance 3 Answers


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