• 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
2
Question by Karsnen_2 · Nov 23, 2012 at 08:23 PM · c#collisionrigidbodyios

[Solved] Is it okay if we change transform.position on a kinematic rigid body which also does not use Gravity?

Hello Devs,

I am in a position to use a rigidbody collider on a GObject. The rigidbody is just for namesake hence it won't be using any Gravity and it will be kinematic. Here on this GObject I am using two functions constantly such as

 this.transform.rotation = Quaternion.Lerp(this.transform.rotation, Angle, Time.deltaTime/2);

and one like this -

 this.transform.position = new Vector3(idealPos.x,(Target.transform.position.y + 40),idealPos.y);



Is it okay to use in on a rigidbody. I would like to stress again that the purpose of a rigidbody is just for the collider which is used for triggering events.

Thank you,

regards,

Karsnen.

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
2
Best Answer

Answer by Montraydavis · Nov 23, 2012 at 08:59 PM

The only physics involved in transform.position is setting the position, so yes, this is perfectly fine.

Pretty much anything in the game can have it's position set to (x,y,z)--regardless of rigidbodies, colliders, etc.

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 Karsnen_2 · Nov 23, 2012 at 09:55 PM 0
Share

Thank you.

avatar image
2

Answer by Owen-Reynolds · Nov 23, 2012 at 09:44 PM

The big warning about rigid bodies and "external" motion (changing `transform.position` yourself) is that it will often break physics. Setting velocity or using AddForce lets physics perform the movement. It can then see two things are going to collide, and bounce them properly.

Just changing position causes the physics to suddenly see overlapping objects. It might blast them apart, or let them overlap, or give a tiny push that looks almost like a proper bounce (so slowly changing position sort-of works on an RB.)

IMHO, `isKinematic` is designed for exactly what you're using it for -- making a no-physics-motion/effects object technically count as one, for purposes of joints or causing collisions.

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 Karsnen_2 · Nov 23, 2012 at 09:55 PM 0
Share

Thank you.

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

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

12 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

Related Questions

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Need help with scripting bug fix. pleease 0 Answers

How to create a damped harmonic oscillation? 1 Answer

Performance Question on Kinematic Rigidbodies 1 Answer

OnCollisionEnter not being called, between a Rigidbody and a Box Collider 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges