- Home /
An odd iTween+RageSpline animation issue with trigger/collider!
So I'm playing with a prototype I made (ok, it's actually a beginning-of-development title, but...), and am encountering what I think is a strange issue. My google-fu has failed me on tracking down the cause of this issue over the course of a few hours, so I am turning to you guys for help =D.
I have a scene set up with a script set to "OnTriggerEnter" as the function attached to a pad, that when the trigger is touched, will move a gate along an iTween path (the collider is attached to the edge I want to act as the trigger). This works fine. However, here's the twist: regardless of collider type used (be it capsule, box, etc. placed to the edge of the object that should fire off the movement event), if the object hitting the collider (this is a ball using a sphere collider) hits at anything OTHER than a straight edge of the trigger collider, it causes the gate to "skip" down for a couple of frames to a location slightly below the path (despite having the object aligned with the path visually for its transform on the pivot point in the editor), then go along the path properly. If the ball hits the collider ON a straight edge, it works 100% fine, no weird skip before the animation plays.
I have been driving myself nuts trying to figure out the "why" of this. I can upload a picture to illustrate if required, but hopefully this is clear enough.
The OnTriggerEnter function does have a check to ensure it's only been hit once, and not trigger again if it's hit again by the ball, since it's meant to be a button-type trigger.
Thanks in advance for any replies!
EDIT: Apparrently it happens regardless just randomly whenever the trigger is used... it isn't related to the angle at all. I tested this by moving the trigger collider beneath the ball, then having it drop straight down... sometimes it would cause the issue, maybe 7/10 times, while the rest it worked fine. Color me confused!
EDIT upon further testing: I'm using the iTween Visual Editor along with the Native extension for C#. The position it moves down a bit to isn't even in anything (it goes down maybe 10 units, using it with RageSpline so 100:1 of normal scale) and then skips back to normal and plays. Apparrently even when playing normally it's going down a scrap first, despite the center point being aligned with the iTween path's start point visually (for some reason it's about 10 units higher than, and 20 units lower than, the actual Position of the gate's Transform, which I've yet to figure out as well).
Answer by Triomferus · Oct 16, 2011 at 07:31 PM
I figured it out... through a bunch of fiddling, apparrently my code was fine. The issue was also unrelated to iTween or RageSpline, but rather how I set up the scene in Unity. After making a new object to test the code with, and having it work fine through many different ways of triggering it, I then tried re-creating the same original glitched object to attach to these triggers and noticed when adding components, the old one had a RigidBody attached. I immediately tried removing the RigidBody from the glitched object and it works perfectly now 100% of the time.
The reason it was sometimes showing as glitching down then snapping to the path was, I am hypothesizing, due to the framerate and timing of the physics fixed time-steps. Sometimes the time-step would miss the frame the pathing triggered in, and by the next frame it already was locked to the iTween path.