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 crazyKnight · Apr 28, 2011 at 01:50 PM · physicsarrow

bow and arrow game

i am making a simple bow and arrow game but i am currently facing some problems in giving a proper feel to how a arrow is actually fired.

i am trying to depict my problem with some images

this is what is happening right now alt text

and this is what i want alt text

basically what i want is to apply a heavy mass on the tip of the arrow so that when it falls it faces the tip of the arrow

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 Proclyon · Apr 28, 2011 at 02:11 PM 0
Share

I think your links broke down, i can't seem to select any. Or is "this" is what is happening right now just pointing at nothing?

6 Replies

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

Answer by AngryOldMan · Apr 28, 2011 at 02:11 PM

I've not actaully tried this but if I were to this is what I would try 1st.

import an arrow model to the game scene. make sure it has the right collider on. Then add two empty game objects to your scene. Move them into position over your arrow, one at the front one at the back then parent them to the arrow. Add a rigidbody component to each of the empty game objects. To the front one turn up its mass to suit and make sure uses gravity is checked. For the back one you will have to estimate how much mass it needs to have relative to the front one, not enough mass and the arrow will face straight down too early, too much mass and it wont tilt enough. i would then add a script to the arrow getting the rigidbody components of the parented empty game objects then applying a consistent gravity multiplied by its mass or turn the masses of the rigidbody to the same (both 10 or something) then apply different strengths of gravity to each one individually.

or on failing that I would add a rigidbody component to the arrow itself and add torque to it depending on how far it was going, so if it was going 360 feet in 1 second (impossible I know but just for simple maths sakes) it would turn (if it was being fired straight/ 90 degrees to the floor) between 10 and 20 degrees/second

Comment
Add comment · Show 2 · 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 Joshua · Apr 28, 2011 at 02:13 PM 0
Share

Hmm, your idea is actually better then $$anonymous$$e I think. If you'd apply gravity to the front rigidbody but not the back one, the back one would simly follow the front one. Done.

avatar image jennfermcm · Sep 16, 2012 at 06:15 AM 0
Share

Torque was the answer for my problem, as you proposed. Thanks!

avatar image
1
Best Answer

Answer by Joshua · Apr 28, 2011 at 02:11 PM

You could either script the parabolic trajectory, which would be giving by a parabolic equation and constantly set the transform to this, or give the arrow more mass and set it's CenterOfMass to something like Vector3(0,1,0), and add in some drag.

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
1

Answer by Owen-Reynolds · Apr 28, 2011 at 02:54 PM

I use this to force projectiles to aim correctly, I'm pretty sure I'm not the first. The two lines in Update do the aiming (it's partial C# code):

bool dead; // uses so we can hang around for a while, after hitting public Transform hitFlash; // the PE when we hit something

void Start () { dead=false; }

void Update () { if(!dead) { Vector3 moveDir = transform.rigidbody.velocity; transform.LookAt(transform.position + moveDir); } }

void OnCollisionEnter(Collision cc) { if(dead) return; // just in case we try to double-die dead=true;

if(hitFlash!=null) Instantiate(hitFlash, transform.position, transform.rotation);

StartCoroutine(killMe()); }

IEnumerator killMe() { // stink in for a while, then drop through the ground: transform.collider.isTrigger = true; // no more collisions transform.collider.isKinematic = true; // freeze in place transform.rigidbody.freezeRotation = true; // not sure I need this transform.rigidbody.velocity = Vector3.zero; yield return new WaitForSeconds(3); transform.collider.isKinematic = false; // drop through ground yield return new WaitForSeconds(3); Destroy(gameObject); }

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 flaviusxvii · Apr 28, 2011 at 02:08 PM

"heavy mass on the tip of the arrow so that when it falls it faces the tip of the arrow"

But all masses fall at the same speed (not accounting for air resistance, which is key). What makes an arrow fly straight (and fall tip first) is the fletching at the back. You can give the fletching some air resistance by turning up Drag.

http://unity3d.com/support/documentation/Components/class-Rigidbody.html <-- Look at Drag.

Comment
Add comment · Show 2 · 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 Joshua · Apr 28, 2011 at 02:16 PM 0
Share

$$anonymous$$asses all fal at the same speed in a vacuum. The rigidbody's drag coefficient uses the density of the object, however. So not changing the drag, but changing the mass, would work fine in this case. "The standard equation for drag is one half the coefficient of drag multiplied by the fluid mass density"

avatar image flaviusxvii · Apr 28, 2011 at 02:41 PM 0
Share

I'm just concerned that making the tip of the arrow overly massive (or inflating the effect of gravity) will have adverse effects. I've always found that making the most realistic approximation tends to give the best results (bereft of silly surprises). Adding drag to the back end would do this best.

avatar image
0

Answer by elJoel · Apr 14, 2017 at 06:04 AM

I know this is old but I was looking for an answer for a long time so here's what I've finally used that worked pretty well: GameObject arrow = Instantiate(crossbowArrow, crossBowShotFrom.position, crossBowShotFrom.rotation); arrow.GetComponent ().AddForce(arrow.transform.forward * crossbowArrowSpeed, ForceMode.VelocityChange); arrow.GetComponent ().AddTorque( arrow.transform.forward * 10 );

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
  • 1
  • 2
  • ›

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

My arrows penetrate walls 2 Answers

2D 360 degress platformer example needed 0 Answers

dynamic path arrows like in endless legends 0 Answers

Rotate towards velocity (2D) 2 Answers

Making an arrow Physics without using rigid body 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