Fangames > Programming Questions
Object Wobble Effect
(1/1)
StuffandThings:
I tried out Klazen's 'wobble' code:
(click to show/hide)//Create event
wobble_speed = 2*pi/room_speed; //speed of the wobble
wobble_distance = 32; //distance of the wobble
aa=0;
//Step event
aa+=wobble_speed;
y = ystart + wobble_distance*sin(aa);
but I want to use it in a slightly different way. I'm trying to figure out how to set it up so that you place an instance in the room, and edit the creation code to have the same effect. It seems that this way, any instance you place will have the same properties and the wobbles will be in-sync. But what if I wanted to control each instance, and make them all wobble differently (instead of making more objects)?
I tried to setup some variables to call from the creation code but I keep getting an error saying "objWobble.(variable) not set before reading it." I tried something along the lines of this:
(click to show/hide)
//Create event
wobble_speed = wobbleSpeed*pi/room_speed; //speed of the wobble
wobble_distance = wobbleDistance; //distance of the wobble
aa=0;
axis = axisStart + wobble_distance*sin(aa); //
//creation code
axis = x;
aixsStart = xstart;
wobbleSpeed = 1;
wobbleDistance = 32;
I know the variables have to be initialized first, but even when I did get GM to accept the code, there was no wobble. How would I set this up?
WetWookie:
In studio the Creation Code takes place after the Create Event so all you have to do are give wobble_speed and/r wobble_distance a different value in the instances creation code. (ie. wobble_distance = 64);
StuffandThings:
wow...I was making that way more complicated than necessary haha. Thanks!
L4Vo5:
You can also change aa to make them start desynchronised
Navigation
[0] Message Index
Go to full version