So im making a egg system and I have the eggs frame set in front on the cameras cframe updated every render step but I was wondering if im constantly setting the cframe how do I make the rotations to give the pet egg a shaking effect like in most popular games Ex: bubble gum simulator?
This is my code so farOk so to create an egg shake side to side, let’s first think about the limits of the movement. The egg should shake up to a maximum angle, which makes it look kinda normal.
Now what I would use would be math.sin() which starts at 0 and goes to 1 and then goes to -1 and then back to 0 in a smooth wave.
Then, just every frame, add something to an iterator, get a multiplier from the math.sin(iterator) and then just set the egg’s rotation based off of the sin’s value.
To stop this interfering with the tween, you’d also need to spin the egg in the z axis in this loop too.
For a cool effect, use math.sin for the x axis of rotation and math.cos for the y value and it will rotate in two different axes in a very pleasant way.
For a more vigourous shake, either increment the iterator faster or increase the max angle of rotation.