• 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
Question by mengkheang · Jun 08, 2015 at 11:05 AM · 2d2d game2d-physics

want to knock gameobject to the same direction as the projectile

Hello im very new to unity I want to knock the gameobject to the same direction as the projectile but unfortunately i was able to knock it horizontally and vertically. im unable to knock it at angle and also this is a 2d game.

any help is much appreciated!

alt text

untitled-drawing.png (17.1 kB)
Comment

People who like this

0 Show 3
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 fafase · Jun 08, 2015 at 11:47 AM 0
Share

Do you really want to send the blue ball in the same direction as red ball? That would look unnatural. Most likely, if you use rigidbody, you pretty much have nothing to do. You send the red ball and let the engine do the rest.

Though if you are in the case the blue should take the red velocity well I just gave you the answer.

Whatever is the velocity of the red is passed to the blue on collision. If you are translating the red then the vector parameter is the velocity, if you use rigidbody you have teh velocity in

  blue.rigidbody2D.velocity = red.rigidbody2D.velocity; 
avatar image mengkheang · Jun 08, 2015 at 12:19 PM 0
Share

no i mean the red ball shoot projectile to hit the blue ball and knock the blue ball to same as the projectile direction that the red ball shoot but i already try with rigidbody would not knock it to the same direction as the projectile that the red ball shoot or maybe i do sth wrong

avatar image fafase · Jun 08, 2015 at 12:20 PM 0
Share

So your red ball is probably translated with something like:

  transform.Translate(direction * Time.deltaTime);

direction * Time.deltaTime in this case is your velocity.

1 Reply

  • Sort: 
avatar image

Answer by Notter · Jun 08, 2015 at 11:37 AM

they do something similar to to what you're asking in this video, about half-way. they shoot a bear with a capsule collider, and apply force where the "projectile" hit, and send the bear flying in that direction.

http://unity3d.com/learn/tutorials/modules/beginner/live-training-archive/fun-with-lasers

Comment

People who like this

0 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 mengkheang · Jun 08, 2015 at 12:19 PM 0
Share

Thanks! will look into that

Unity Answers is in Read-Only mode

Unity Answers content will be migrated to a new Community platform and we are aiming to launch a public beta by June 9. Please note, Unity Answers is now in read-only so we can prepare for the final data migration.

For more information and updates, please read our full announcement thread in the Unity Forum.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Sprites not recognized as whole-spinning in different directions 0 Answers

Two Polygon2D Collider do not Collide with Each Other (Solved) 2 Answers

simulate gravity in a 2D game 3 Answers

Why does BoxCollider2D distance depend on distance to camera center? 0 Answers

How to have coins burst out in random directions after destroying an object in unity? 2 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