• 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 sean244 · Nov 29, 2017 at 06:57 PM · 2d game2d-physics

How to make an object move without assigning a rigidbody to it

I have a gameobject that goes up and down by itself. The code is very simple

  void FixedUpdate ()
 {
     rb.velocity = new Vector2(rb.velocity.x, dir);
     
     if (transform.position.y > start)
         dir = Mathf.Abs(dir) * -1;

     else if (transform.position.y < end)
         dir = Mathf.Abs(dir);
 }

However, I don't like the fact that it has a rigidbody, because I don't want its movement to be affected when another object eventually collides with it. So would it be possible for the object to continue moving up and down by itself without a rigidbody?

EDIT

Thanks to MT369MT for the solution

I simply replaced

  rb.velocity = new Vector2(rb.velocity.x, dir);

with

   transform.Translate(Vector2.up * speed);

Comment

People who like this

0 Show 0
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

1 Reply

· Add your reply
  • Sort: 
avatar image
Best Answer

Answer by MT369MT · Nov 29, 2017 at 07:28 PM

Hi, Try using transform.Translate that doesn’t need a rigidbody.

Comment
sean244
aseay4
MarcoChavarin

People who like this

3 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 sean244 · Nov 29, 2017 at 08:11 PM 0
Share

Thanks. Worked Perfectly :)

avatar image MuttlyMartin · Sep 26, 2021 at 04:13 PM 0
Share

how would you get that to move smoothly though? iv done a similar thing with translate and it seems to snap to positions

this.gameObject.transform.Translate(Vector3.down theMadHatAttacks.attackValueUp Time.deltaTime);

also it keeps moving slightly as it runs though it with IEnumrators thats probably because its slightly out of place with its starting position though

avatar image Legacy_Primo MuttlyMartin · Mar 18, 2022 at 03:05 PM 0
Share

Would Time.fixedDeltaTime work for it?

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

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

Related Questions

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

Play and Stop Animation 1 Answer

I am very new to unity and I'm looking for advice on a targeting system( or if i'm setting myself up for failure) 1 Answer

[2D] Moving the player 1 tile at a time using rigidbody movement 0 Answers

Tilemap Collider 2D not generating colliders...,Tilemap Colliders won't generate.... 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