• 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 Mistmash · Apr 06, 2016 at 06:14 PM · transformobjectwrap

Transforming a moving 3D Object is altering the direction

I am creating a Braitenberg simulation and am trying to implement a screen wrap function. My vehicles are cubes with cylinders attached with hinge joints to create wheels, the back wheels are powered by a motor to produce movement that varies depending on environmental factors.

My issue is that when I transform my vehicle components on collision with a wall, the vehicle jerks and changes direction of movement after transforming. See image below.

http://imgur.com/a/PfpUE

I am currently using this code to transform the body and wheels of the vehicle within my vehicleController script, I feel the issue may be that i am transforming them individually but I do not know how else to do it as the vehicle parent transform does not hold the current position.

 Vector3 flip = transforms[1].position;
             Debug.Log(flip);
             flip.z = -(flip.z);
             Debug.Log(flip);
             transforms[1].position = flip;
             
             for(int i = 4; i < 8; i++)
             {
                 flip = transforms[i].position;
                 flip.z = -(flip.z);
                 transforms[i].position = flip;
             }

With transform[1] being the body and transform[4-7] being the wheels.

Thanks

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

0 Replies

· Add your reply
  • Sort: 

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Adding data to a set of transforms 1 Answer

Moving an object towards a clicked object 1 Answer

Lerp a Object along X and Z axis only. 3 Answers

How do you move an object through script 1 Answer

How to get the constant Y rotation of the camera 2 Answers

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