Here is an example of the mechanic I'm trying to mimic for another project (you only need to see the rotating T shapes): http://www.youtube.com/watch?v=cftX1ShGSC4&t=0m20s
Using a hinge joint and some of this make-shift code below, I was able to get a pretty nice snapping effect, but of course while the player was present in my collider, all sorts of wackiness would happen.
var playerPresent : boolean = false;
function Update () {
if (playerPresent == false){
var vec = transform.eulerAngles;
vec.y = Mathf.Round(vec.y / 90) * 90;
transform.eulerAngles = vec;
}
}
function OnTriggerEnter(collisionInfo : Collider) {
if (collisionInfo.tag == "Player"){
playerPresent = true;
}
}
function OnTriggerExit(collisionInfo : Collider) {
if (collisionInfo.tag == "Player"){
playerPresent = false;
}
}
The strangeness of the T-shape, changing orientations, and my lack of personal coding experience made an attempt at this same situation with raycasting near impossible as well. I would much appreciate any help or clues, thank you.
↧