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 /
  • Help Room /
avatar image
0
Question by ahmadgml32 · Mar 05, 2021 at 08:54 PM · rigidbodyprojectilerangecalculatespeedometer

how to calculate speed with in range value.

I made a projectile script and it works just fine but it needs some upgrades like calculating range using speed and gravity or range with speed and gravity just to make everting more clear than now script is using rigid body to add force to the projectile finally sorry for bad english.

Comment
Add comment
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 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by tylerdtrudeau · Mar 05, 2021 at 09:15 PM

Im not sure what you are trying to achieve. Do you want the projectile to have a constant speed? keep accelerating? slow down due to drag? Do you want the projectile to slowly drop due to gravity like a bullet would shot over long distances? theres alot of info needed about what youre trying to do before anyone can really help you achieve it.

Comment
Add comment · Show 3 · 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 ahmadgml32 · Mar 08, 2021 at 04:27 PM 0
Share

I already did all stuff above but i have speed var isnted of range so what i want to do is get auto speed when set range value with my rigidbody so for example when i set range to 100m it sets speed to fit this range or just calculate range value from speed hope u got my meaning

avatar image tylerdtrudeau ahmadgml32 · Mar 08, 2021 at 04:58 PM 0
Share

Sorry but those sound like 2 different things. Set speed and find range is constant speed with variable time depending on range. Calculate range based off of speed would be constant time with variable range depending on speed.

lets try some examples to get some clarification.

eg 1 - If you have a set range (say 100m) and you want to set the speed to reach that range (for ease of calculation lets say 10m/s so it takes 10 seconds to reach the target) then if you change the target to 50m away it will only take 5 seconds to get there as the speed is 10 m/s. so this is constant speed but variable time depending on range.

eg 2 - You have a flight time of 10 sec before projectile hits the ground/ stops. If you set the speed to 12 m/s then with simple multiplication you can deter$$anonymous$$e the range to be 120m. if you increase the speed then the range increases and vise versa. So thats a super simplified way of finding range with time and speed.

eg 3 - Now if you want to go super realistic and factor all the variables in that modern FPS games do and update velocity dynamically based off range it gets alot more complicated. You need to factor in gravity (9.81 m/s^2) to deter$$anonymous$$e how quickly the bullet is being pulled downwards aka its flight time, if the bullet is fired straight horizontal its super easy, if its fired slightly upwards (like a snipers long shot) then you need to do some trigonometry to get the vertical component of the velocity and use gravity to establish flight time. You will need to calculate in drag of the projectile to deter$$anonymous$$e how fast its slowing down and therefore its velocity is dynamic throughout the flight. Finally once you have an equation to figure out all this stuff then you can simply plug in the range and it will tell you the velocity that the bullet needs to be fired at to reach the target. If you keep everything as horizontal shots then the time to reach the target should always be same as a bullet falls vertically at the same speed regardless of horizontal velocity (whether you drop it from 2m high or fire it from a gun 2m high that is pointing straight sideways) (lets ignore curvature of the earth for longer shots to make it easier)

if eg 3 is what youre looking for I would start by leaving gravity on but reducing all drag to 0 as a start point. once you have that working properly then intoduce drag back into it and adjust you calculations to reflect that. Just start simple then add one layer of complexity at a time and test/ debug every step to make sure youre getting the desired results.

avatar image ahmadgml32 tylerdtrudeau · Mar 08, 2021 at 09:24 PM 0
Share

Thx bro this is little bit complex but i will try it thx.

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

202 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

Related Questions

Issue with shooting projectiles in the direction of the arrow keys 1 Answer

Unity glitches using Ridigbodies as bullets in multiplayer- am I missing something? 0 Answers

How would one go about implementing Unreal's Suggest Projectile Velocity function in Unity? 1 Answer

Is there any good sample code for shooting a projectile and collision detection? 0 Answers

Projectile throw in 3rd person 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