x


Rotating bridge

Hey,

I am want trying to create a rotating bridge for my marble rolling game.

The bridge is rotating 90 degree under 0.5 seconds, then waits 2 seconds, and rotate 90 degrees again. And it is doing it the whole time. I am rotating it with transform.rotate (but my marble has a rigidbody, and moves by force)

But when I want my marble to stay on the bridge, and rotate with it, I am having troubles.

Here is how I set it up: There is the bridge, with a box collider, and a slightly smaller triggerer child above it. The bridge has the rotating script, and the triggerer has the following script:

var stickMain     : stickRot;
var playerM        : GameObject;
var player       : GameObject;

function OnTriggerEnter (other : Collider)
{
    if (other.tag == "Player")
    {
       player.transform.parent = stickMain.transform;
    }
}

function OnTriggerExit (other : Collider)
{
    if (other.tag == "Player")
    {
       player.transform.parent = playerM.transform;
    }
}

This setup does not work as excepted. Most of the time, "artifacts" appear, like the scale of the marble changes, or the marble teleports to the other side of the bridge. But sometimes, when the marble is entering the bridge slowly, it works.

I am looking for suggestion/ideas for this problem.

Thank you for you help!

more ▼

asked Apr 08 '12 at 11:22 AM

Dreeka gravatar image

Dreeka
129 50 62 65

Try other.collider.gameObject.CompareTag("Player") instead. Also, what is stickRot?

Apr 08 '12 at 12:49 PM Kleptomaniac

Stickrot is the script class I use for the rotation, I just forgot to remove it.

other.collider.gameObject.CompareTag("Player") gives the same resoult.

Apr 08 '12 at 12:56 PM Dreeka

So is stickMain a gameObject then?

Apr 08 '12 at 01:36 PM Kleptomaniac

No, it is a custom class.

I have also discovered, that non uniform scaled child can cause problems. My marble is (0.6, 0.6, 0.6) in scale. Can that cause problems?

Apr 08 '12 at 01:40 PM Dreeka

I don't think it should ... not too familiar on classes ... why are you using that instead of a gameObject?

Also, are you getting any errors? Might be wise to try chucking some Debug.Logs in your OnTrigger() functions to see whether you're actually getting there.

Apr 08 '12 at 01:56 PM Kleptomaniac
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

Well, I managed to get it work.

I have used a new variable (as Kleptomaniac suggested), and set everithing to scale 1 (I have read it can cause parenting issue). Now it works fine.

more ▼

answered Apr 09 '12 at 01:51 PM

Dreeka gravatar image

Dreeka
129 50 62 65

(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:

x135
x1

asked: Apr 08 '12 at 11:22 AM

Seen: 321 times

Last Updated: Apr 09 '12 at 01:52 PM