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 oldsoul · Aug 22, 2011 at 05:33 PM · rigidbodyobjectgravityfloating

Turret floats away and pushes everything away from it

For some reason when I apply this script to my turret:

var LookAtTarget:Transform; var damp = 1.0; function Update ()

{ if(LookAtTarget) { var rotate = Quaternion.LookRotation(LookAtTarget.position - transform.position); transform.rotation = Quaternion.Slerp(transform.rotation, rotate, Time.deltaTime * damp); }

 //transform.LookAt(LookAtTarget);

}

It pushes any other objects nearby away, floats around, and when I get near it with the target it is tracking it floats up higher until I get farther away. I have trolled around looking for this exact problem and have not found any solutions posted to this question, I am fairly new to unity so I am certain it is just some stupid setting I am not familiar with. I have messed with rigidbody and other gravity settings trying to get something to work, but the object doesn't pay any attention to my feeble attempts.

Any suggestions are much appreciated!

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
0

Answer by Joshua · Aug 22, 2011 at 06:53 PM

You've probably given the body of the turret a rigidbody. Remove this. You don't want the gun to react physically realistically, eq push itself away.

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
avatar image
0

Answer by oldsoul · Aug 22, 2011 at 07:01 PM

No, it doesn't have any rigidbody dynamics assigned to it right now. I have tried adding physics to it through the inspector tab and scripting, but nothing gets it to "act right." It just goes ape-S*** if you try to assign anything to it really. Probably worth noting I made the sphere (body), cylinder (barrel), and cube (base) and didn't import them, I don't know if that made me skip a step or what have you...

Comment
Add comment · Show 6 · 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 Joshua · Aug 22, 2011 at 07:09 PM 0
Share

Please don't answer your own question if you want to comment - there's a button to do that. It makes others less likely to answer.

An object doesn't move unless you make it move somehow. If you haven't assigned a rigidbody component to any of the parts that make up the turret then you're moving it through script somehow. The only other option is that transform.rotation is rotating it around it's pivot, like it should, and you've put it's pivot at the wrong place.

avatar image oldsoul · Aug 22, 2011 at 07:27 PM 0
Share

Well I've cut my script down to the most basic parts: var LookAtTarget:Transform; function Update () { transform.LookAt(LookAtTarget); } And it still moves around and floats when I get near it. But also, any other nearby objects get pushed way far away. I don't know how in the world it is doing it. When I disable the script, it doesn't do it. I'm really pretty dumbfounded how it could be doing this. I have to take off for now, so if I don't reply for a while sorry.
Thanks both of you for your help though!

sorry, didn't know that about answer vs comment button.

avatar image Joshua · Aug 22, 2011 at 07:31 PM 0
Share

Take a close look at where the pivot is at.

avatar image oldsoul · Aug 22, 2011 at 07:57 PM 0
Share

I'm guessing you mean pivot / center button? I just switched it back and forth a few times and it didn't have any affect on what it is doing. Interesting, when it is set to pivot, the handle is way the heck out in front of it. Does that need to be moved, should it be set to just pivot and not center? Or is that not important? I gotta run, thanks for the help again!

avatar image Joshua · Aug 22, 2011 at 08:03 PM 0
Share

Never put that button on center, put it on pivot. The pivot is the point around which an object moves and rotates. If you set it to pivot and the handle is not where you want it's physical center to be then you've found the cause of the problem. Put everything childed to it in the correct place and it should behave as expected.

Show more comments

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

changing gravity for one object. 5 Answers

My rigidbody gets destroyed 2 Answers

Gravitational pull without losing speed 1 Answer

RigidBodys Suddenly Heavier 1 Answer

Turn Gravity on when collision occurs 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