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
0
Question by helloiam · Mar 23, 2013 at 10:04 PM · movesmoothballshootbomb

Shoot a bomb to mouse position smooth

I want to make that when I shoot that a sphere which I made goes smooth to my mouse position so like a cannon that is shooting, what I made yet is that it goes to my mouseposition but it's not like shoot it goes directly.

 void shootInput()
     {
         cannonShot.Play();
 
         journeyLength = Vector3.Distance(spot.position, pos);
 
         float distCovered = (Time.time - startTime) * 20f;
         float fracJourney = distCovered / journeyLength;
 
         depth = 15f;
 
         pos = Camera.main.ScreenPointToRay(Input.mousePosition).GetPoint(depth);
 
         Rigidbody ball = Instantiate(cannonBall, spot.position, Quaternion.identity) as Rigidbody;
 
         //ball.rigidbody.MovePosition(Vector3.Lerp(spot.position, pos, fracJourney));
 
         ball.rigidbody.AddRelativeForce(Vector3.left * 20000000000f);
 
         cannonTop.transform.LookAt(pos);
     }

Please help me and aks question if you didn't understood me.

alt text

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 Unitraxx · Mar 23, 2013 at 10:09 PM 0
Share

try lowering the force value at

 ball.rigidbody.AddRelativeForce(Vector3.left * 20000000000f);

from 20000000000 to something like 200.

Some questions :

What exactly happens, and from what is spot.position the position?

1 Reply

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

Answer by helloiam · Mar 23, 2013 at 10:55 PM

http://imageshack.us/photo/my-images/69/bombc.png/ <--- image of my project

What I want to do is shoot forward with the cannnon and hit other objects what is falling down on screen.

It is working if I work with ( ball.rigidbody.MovePosition(Vector3.Lerp(spot.position, pos, fracJourney)); ), but what it does then it creates direct a cannonball on my mouse position.

What I want is that when I click that it goes from a beginning point which is in front of the cannon and then it's shooting from my cannon to my mouse position (of course when I click). And of c oouse the ball is going smooth like it's shooting to my mouse position, my code does a little but it needs more work but hopefully you guys can help me out with this issue, thank you all!

Comment
Add comment · Show 4 · 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 Unitraxx · Mar 23, 2013 at 11:07 PM 0
Share

Did you even read my answer/question? Do you have an empty gameObject in front of you cannon where you can spawn the the projectile ?

avatar image helloiam · Mar 23, 2013 at 11:10 PM 0
Share

Yes I have, and it is not working like I want

avatar image Unitraxx · Mar 23, 2013 at 11:21 PM 0
Share

and what about the spot.position question ?

avatar image helloiam · Mar 23, 2013 at 11:24 PM 0
Share

spot.position is the begin position so where the projectiles must spawn, take a look of this picture: http://imageshack.us/photo/my-images/69/bombc.png/

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

11 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

Related Questions

Smooth platformer Movement (horizontal) 0 Answers

Smooth Move script for my spaceship 0 Answers

smooth motion 1 Answer

How do I spread a movement over several frames instead of one? 1 Answer

moving a ball when touch 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