- Home /
How can I create an animation of platforms
Hi guys. I want these platforms to get activated and start rising in case a player passes by, or moving randomly according to music as equalizer, can you help me?
Answer by behzad.robot · Apr 13, 2013 at 02:26 PM
Well i think i may be able to help a little bit: -Create a zone script and attach it to a big box which is covering the boxes and some space around them then remove the mesh renderer component for sure then make it's collision as a trigger this Zone's script will call a function attached to father of these boxes which this function is going to make the boxes moving randomly. Zone.js:
public var Boxes:GameObject;
function OnTriggerEnter(other:Collider)
{
if(other.gameObject.tag=="Player")
{
Boxes.GetComponent(Shuffler).Shuffle();
//well lets call that funciton Attached to Boxes father Shuffle
}
}
Shuffler.js(Attached to boxes father):
public var children:GameObject[];
public var MaxForce:Vector3;
function Shuffle()
{
//well u can replace any other algoritm u want to here !
for(i=0;i<children.length;i++)
{
//lets genrate some random force u may need to adjust this part a little bit if u dont want them to go all around!
var randomForce:Vector3;
randomForce.x=Random.Range(-MaxForce.x, MaxForce.x)
randomForce.y=Random.Range(0, MaxForce.y)
// i made it between 0 and max force caz i thought u wont need to shoot them down and then have them bounce back :/
randomForce.z=Random.Range(-MaxForce.z, MaxForce.z)
children[i].rigidbody.AddForce(randomForce)
}
}
az i've told u before u may need to adjust algoritm used in shuffle function but i just tried to help and i've gotta admit i have no idea what to do about them music thing but u can add an increasing force algoritm instead of this random thing so that each of them is jumping more (or maybe less ) than the one before it that's good idea i think.:D
Your answer
Follow this Question
Related Questions
Platform Triggers & Animation 0 Answers
Can the animation editor create local rotational data? 3 Answers
Adding animation clips via script 2 Answers