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 Hybris · Mar 22, 2012 at 08:19 AM · rigidbodymovingtransform.translate

Moving this object?

Hello, I'm trying to make a ship in the ocean and it has to collide with the continents, but I can't get it to move good, with transform.translate it ignores the colliders and I tried using rigidbody.MoveTowards but then I can't control the rigidbody's direction this is my script:

 function Update () {

 rigidbody.rotation = transform.rotation;

 var forward = Vector3.right * -Speed;

 if(Input.GetAxis("Vertical")){
      transform.rigidbody.MovePosition(rigidbody.position + forward * Time.deltaTime);
 
 }

 var rotate = Input.GetAxis("Horizontal") * RotSpeed * Time.deltaTime;

 transform.Rotate(0, rotate, 0);

 }

I need to finish this pretty quick so plz react quickly, thanks in advance.

Hybris

SOLVED: What I did is combine transform.translate with a rigidbody component to the object, I gave the rigidbody a "mass" of "Infinity" and disabled "use gravity"

Thank you guys for answering so quick.

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 Hybris · Mar 22, 2012 at 05:11 PM 0
Share

SOLVED: What I did is combine transform.translate with a rigidbody component to the object, I gave the rigidbody a "mass" of "Infinity" and disabled "use gravity"

Ps: This was for the people to lazy to read my question. XD

2 Replies

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

Answer by AlucardJay · Mar 22, 2012 at 03:52 PM

To 'push' rigidbody's around : http://unity3d.com/support/documentation/ScriptReference/Rigidbody.AddForce.html

 if(Input.GetAxis("Vertical")){
     rigidbody.AddForce (forward * Time.deltaTime);
 }


Comment
Add comment · Show 3 · 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 Hybris · Mar 22, 2012 at 04:54 PM 0
Share

I can't steer and you keep going forward if you pressed once.

avatar image AlucardJay · Mar 22, 2012 at 05:06 PM 0
Share

so there is no drag with a ship in water ? and you are using rigidbody ?

To push the ship , use AddForce : http://unity3d.com/support/documentation/ScriptReference/Rigidbody.AddForce.html

To turn the ship , use AddTorque : http://unity3d.com/support/documentation/ScriptReference/Rigidbody.AddForce.html

or , if you are not using the physics : http://unity3d.com/support/documentation/ScriptReference/CharacterController.$$anonymous$$ove.html

avatar image Hybris · Mar 22, 2012 at 08:00 PM 0
Share

I can't use AddForce cuz I lose the control over the object. I tried the character controller it doesn't work, I fall down. I will look in the AddTorque. This question is solved, but just keep throwing answers here, that way we will keep learning! yay! XD

avatar image
1

Answer by DaveA · Mar 22, 2012 at 08:45 AM

Try http://unity3d.com/support/documentation/ScriptReference/Rigidbody.MoveRotation.html

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 Hybris · Mar 22, 2012 at 02:44 PM 0
Share

Tried it couldnt get it to work

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Why is my object not following my path ?,Why is my object going through the target ? 2 Answers

Cant fall down while moving. 1 Answer

Prevent Player to push Rigidbody 0 Answers

Light bulb moving HELP 1 Answer

Something on a moving platform 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