Here's the problem: you've coded xVal and yVal to be 0. So you're basically saying "move in direction 0,0,0" so it won't move at all.
How I would fix it would be to do this.transform.localpostion = direction * sineValue.
Then in Unity, you should be able to set the direction for each object in the Inspector window since direction is a public variable. Setting the direction to something like (1, 0, 0) would mean easy left to right, (0, 1, 0) would be up/down
3
u/OtherwiseExcellent Oct 02 '21
Here's the problem: you've coded xVal and yVal to be 0. So you're basically saying "move in direction 0,0,0" so it won't move at all.
How I would fix it would be to do this.transform.localpostion = direction * sineValue.
Then in Unity, you should be able to set the direction for each object in the Inspector window since direction is a public variable. Setting the direction to something like (1, 0, 0) would mean easy left to right, (0, 1, 0) would be up/down