Continuous Rotation Problem


All I am trying to do is to make an object, a small cylinder in this case, spin in around one axis, the x axis as it is bobbing up and down. Right now I have a script that rotates it a fixed amount in the update function. The code looks as such,

void start(){
    origin = this.transform.position;
    rotation = new Vector3(3.0f, 0.0f, 0.0f);
void update(){
    Vector3 pos = new Vector3(0, origin.y + Mathf.Sin(Time.time/speed)*distance, origin.z);
	this.transform.position = pos;

When I attach this script to an object, it spins and moves like I want it to, but I’m running into a weird problem. As soon as I start my game and the cylinder starts spinning, my player gets nudged around a bit and sometimes is launched into the air for no reason. There isn’t anything touching the player and I’ve checked the collider dimensions and they all seem fine. The player and the cylinder are not touching when this happens but it only happens when the cylinder spins. If I comment out the this.transform.Rotate(rotation), everything is fine.

Also when I have the cylinder spinning, the player doesn’t collide with it. When I comment out the rotates, the player can collide with it no problem.

Any ideas on what the heck is going on?

Edit: Added code for the objects movement.

Play it and go to Scene view. Select your rotating object. Watch the collider. Maybe it’s way off, like a yo-yo, so is slamming you. Or it just dips underground half the time, which is why you don’t hit it.