x


object rotating around parent

i have this to make my tyres move

tyre1.transform.Rotate(Vector3.forward * Time.deltaTime * movespeed * 5);
tyre2.transform.Rotate(Vector3.forward * Time.deltaTime * movespeed * 5);
tyre3.transform.Rotate(Vector3.forward * Time.deltaTime * movespeed * 5);
tyre4.transform.Rotate(Vector3.forward * Time.deltaTime * movespeed * 5);

not the whole script^^

the tyres rotate around the parent race car instead of rotating normally how do i make them rotate normally?

more ▼

asked Nov 18 '11 at 06:57 AM

sam32x gravatar image

sam32x
178 38 56 62

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

You need to make sure that the tyres' pivot points are in the right locations! From the sounds of things, each tyre's pivot point is the centre of the car, not the centre of the wheel. Make sure you have your handles set to 'pivot' not 'centre'- and if you can't change the models to be right, try adding intermediate empty game objects which have the correct pivot point, between the car and the wheels on the transform hierarchy.

more ▼

answered Nov 18 '11 at 07:02 AM

syclamoth gravatar image

syclamoth
14.8k 7 15 80

nope the origin is in the right place

Nov 18 '11 at 07:09 AM sam32x

wait actually they are rotating around the center of the 4 tyres

Nov 18 '11 at 07:12 AM sam32x

Well, then I can't explain it. It should definitely be working the way you want it, unless there's something you haven't told me.

Nov 18 '11 at 07:13 AM syclamoth

heres the whole script

var movespeed = 0;
var turn = 0;
var maxspeed = 16;
var minspeed = -8;
var breakspeed = 0.2;
var tyre1 : GameObject;
var tyre2 : GameObject;
var tyre3 : GameObject;
var tyre4 : GameObject;


function Update () {
transform.Translate(Vector3.left * Time.deltaTime * movespeed);
transform.Rotate(Vector3.up * Time.deltaTime * turn);

tyre1.transform.Rotate(Vector3.forward * Time.deltaTime * movespeed * 5);
tyre2.transform.Rotate(Vector3.forward * Time.deltaTime * movespeed * 5);
tyre3.transform.Rotate(Vector3.forward * Time.deltaTime * movespeed * 5);
tyre4.transform.Rotate(Vector3.forward * Time.deltaTime * movespeed * 5);

if (Input.GetKey("space")){
movespeed -= breakspeed;
}

if (Input.GetKey("a")){
turn -= 10;
 }

if(Input.GetKey("d")){
turn += 10;
}

  if (Input.GetKey("w")){
movespeed += 1;
  }

   if (Input.GetKey("s")){
  movespeed -= 1;
}
if (movespeed >= maxspeed){
movespeed = maxspeed;
}

if (movespeed <= minspeed){
movespeed = minspeed;
}

if (turn >= 0){
turn -= 5;
}

if (turn <= 0){
turn += 5;
}

if (turn >= 135){
turn = 135;
}

if (turn <= -135){
turn = -135;
}

if (movespeed <= 0){
breakspeed = -0.02;
}

if(movespeed >= 0){
breakspeed = 0.02;
}
}
Nov 18 '11 at 07:22 AM sam32x

oh wait i can just do an animation and change the speed

Nov 18 '11 at 07:36 AM sam32x
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

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

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3331
x725
x534
x57

asked: Nov 18 '11 at 06:57 AM

Seen: 752 times

Last Updated: Nov 18 '11 at 07:46 AM