Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
This question was closed May 18, 2019 at 04:27 PM by Aonex for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by Aonex · May 16, 2019 at 07:24 PM · collisionvr

Cant get arrow to stick

I can't get the arrows to stick, they collide properly with everything. I just can't seem to figure out how to get it to stick now.

There are two scripts one is for managing the arrows and the other for firing.

ArrowManagerScript

 private void Fire(float strDist)
 {
     currentArrow.transform.parent = null; //detach arrow from all parants
     Rigidbody r = currentArrow.GetComponent<Rigidbody>();
     r.velocity = currentArrow.transform.forward * arrowPowerMultiplyer * strDist;
     r.useGravity = true;
     r.isKinematic = false;
 
     stringAttachPoint.transform.localPosition = stringStartPoint.transform.localPosition; //rest string
 
     currentArrow.GetComponent<Arrow>().Fired();
     currentArrow.GetComponent<Collider>().isTrigger = false;
     Destroy(currentArrow, 4f);
         
     currentArrow = null;
     isAttached = false;
 }

ArrowScript

 public bool isFired = false;

 // Update is called once per frame
 void Update()
 {        
     if (isFired)
     {
         transform.LookAt(transform.position + transform.GetComponent<Rigidbody>().velocity);// make arrow lookat where it is going like an arrow
     }
 }

 public void Fired()
 {
     isFired = true;        
 }

 private void OnTriggerStay(Collider col)
 {
     if (SteamVR_Actions._default.GrabPinch.GetStateDown(SteamVR_Input_Sources.RightHand)) //if trigger pulled
     {
         ArrowManager.Instance.AttachArrowToBow(); //attach arrow to bow
     }      
 }

   

I am hoping to get the arrow to stick, Also the arrow script is attached to an arrow prefab and the arrowmanager is attached to the SteamVr rightHand

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 MadDevil · May 17, 2019 at 07:34 AM 1
Share

Try using fixed update rather than update. You should always do your physics calculation in fixed update.

The other alternative is try using raycast and position to deter$$anonymous$$e if your arrow is in front of your target or back. so if it has passed the target you can manually stick it to the target.

2 Replies

  • Sort: 
avatar image
0

Answer by tormentoarmagedoom · May 17, 2019 at 08:21 AM

Hello.

I did not read the code, but the solution is so simple.

Just need to detect when the arrow touched the objective, and then just need to make te objective parent of the arrow!

 Arrow.transform.parent = Objective.transform;

Bye!

Comment
Add comment · 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
0

Answer by Aonex · May 17, 2019 at 12:20 PM

@tormentoarmagedoom Thank for the response :). I have tried implementing this and it still seems not to detect the collision between the arrow and target. I made sure to disable the trigger when the arrow is fired as well. I also tried making two game objects and comparing if they hit one another with no avail.

Comment
Add comment · Show 1 · 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 Reedex · May 17, 2019 at 08:49 PM 1
Share

hi so i been doing the same just the other day, and all i did was after the hit, i set the arrows rigidbody to kinetic and parent it to other.(assu$$anonymous$$g its scale is 1,1,1)

Follow this Question

Answers Answers and Comments

192 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

Related Questions

OVR Grabbable causes object to ignore OnCollisionEnter/Exit 2 Answers

Sword slashing logic on Gear VR using controller? 0 Answers

Destroy object after time Only if raycast is colliding; 0 Answers

Ignore Collisions with SteamVR Teleport Area? 1 Answer

Object possibly registering too many collisions with player (VR) 0 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