• 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 yosh 1 · Feb 24, 2011 at 09:59 AM · throw

lobbing to certain position

im still blur how to solve this one..

im using this code for lobbing the grenade.. but this code need to adjust y to get more distance.

var instantiatedProjectile : Rigidbody = Instantiate( projectile, transform.position, transform.rotation ); instantiatedProjectile.velocity = transform.TransformDirection( Vector3( 0, 15, speed ) ); Physics.IgnoreCollision( instantiatedProjectile. collider, transform.root.collider );

what i want to do is throw the grenade in specific position.

i hope somebody can help me..

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

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Joshua · Feb 24, 2011 at 11:04 AM

Well, you transform the direction of the velocity in Vector3(0, 15, speed). This is the speed in x, y, z. So to change the speed in which it is thrown in the y-direction change the 15 to something higher. Or, even better, at the top of your script type var height = 15.0; amd where the 15 stands type height. Now you can change the height without going into the script. :)

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 yosh 1 · Feb 25, 2011 at 01:14 AM 0
Share

no i mean, i want to throw object into pos Vector3(100,0,100). i want to ignore the speed or angle.. angle n speed will be static..

avatar image
0

Answer by yosh 1 · Feb 25, 2011 at 01:20 AM

i also found this code that shown what i want, but i need somebody help me.

cTime += 0.01f;

   Vector3 currentPos = Vector3.Lerp(startPos, endPos, cTime);

         currentPos.y += trajectoryHeight * Mathf.Sin(Mathf.Clamp01(cTime) * Mathf.PI);

         transform.position = currentPos;

if i use this code, the physic is not working. if i throw the object to the wall, then the object will go through the wall. i have add rigidbody, but also not working, because i think the object force to go to the position that i have set before.

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

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

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

Throw stuff! Instantiate preFab from game object to raycast point, at least I'd like to. 1 Answer

Script c+.How i throw player to any area.? 1 Answer

Add force to mouse position? 0 Answers

How to make character pick up objects? 1 Answer

Throw the Player from the Enemy away 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