Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 overunity3d · Jul 30, 2011 at 03:59 AM · addforceforcepositioningtrajectorymomentum

Trajectory problem with addforce coordinates

The basic tenant is to 'Fire and forget'... No matter where I turn the projectile should remain on target.

I fire a projectile in a GameObject. It travels away from the viewer towards a target in the distance. When I spin the GameObject on the x or y axis, the projectile's postion spins with the environment. In other words the projectile is heading towards the target. When I stop the GameObject from spinning the original trajectory takes over and the projectile is once again going away from the viewer when it should maintain it's course towards the original target. So the position of the projectile follows the GameObject's positioning but the trajectory does not maintain course. I could call this a feature, but I need a realistic play at first. It is always away from the viewer or if it hits something and bounces off that is the new trajectory even though the world is rotating. I believe I am mixing component/local values with world values although I am not sure what to check. Has anybody else seen this?

TIA

The GameObject is a GameObject not a rigidbody. The projectile is

  var Pulsarshoot = Instantiate(Pulsarshoot,  GameObject.Find("SpawnPoint").transform.position,Quaternion.identity);
  Pulsarshoot.rigidbody.AddForce(transform.forward * 50000);
  Pulsarshoot.transform.parent = GameObject.Find("cueb").transform;

as a rigidbody. Spawnpoint is a rigidbody.

I believe this is the culprit:

Pulsarshoot.rigidbody.AddForce(transform.forward * 50000);
The force is coming from the rigidbody spawnpoint, correct?

Comment
Add comment · Show 2
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 SilverTabby · Jul 30, 2011 at 04:13 AM 0
Share

First, is this a GameObject or a Rigidbody? It seems like you are describing rigidbody movement.

Actual problem:

You create a GameObject with rotation (0,0,0) at (0,0,0). Up (local up) is (0, 1, 0)

You rotate it 90 degrees on the X axis. Local Up is now (0, 0, -1). See the problem?

If you ONLY move using ABSOLUTE values, then this should not be a problem.

avatar image aldonaletto · Jul 30, 2011 at 06:34 PM 0
Share

I've edited my answer - take a look below:

1 Reply

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

Answer by aldonaletto · Jul 30, 2011 at 04:16 AM

It seems you're using some vector from the original GameObject to apply force to the projectile after launched - if the projectile was launched with only an initial velocity or force, its trajectoy would be independent of the launcher.
But this is only speculation, because you've not posted your code. Post the code and we can check what's wrong.

EDITED: Based on your code, I suppose the real problem is the parenting to the "cueb" object (whatever it is). Since the projectile is a child of this object, any rotation or movement the object does will affect the projectile as well.
The initial force is ok: it should really follow the fire and forget rule, since it's applied only once - you would have problem only if the force was being applied during the trajectory.
If you need to child the projectile to something for any reason, make sure the parent object will not rotate or move while the projectile is alive. The rule is: child movements do not affect the parent, but parent movement DOES affect the child.

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 overunity3d · Aug 07, 2011 at 10:15 PM 0
Share

In this case the child maintains its position with the parent but the force applied to the child for a given trajectory does not rotate with the parent. I fire, the projectile goes away from the instantiation point. When I rotate the parent 180 degrees the projectile is co$$anonymous$$g at the instantiation point. Reparenting does not help. I don't know to make this any clearer. I have spent days trying to get this to work. Is it because the main camera is not in the parent object but outside watching everything rotate?

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Why is force only being added in the same direction? 1 Answer

AddForce to object 3 Answers

AddForce to the Left? 3 Answers

add force to object that has 2 different rigid bodies 0 Answers

How do I apply a force to the other object in a collision? 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