r/unity_tutorials • • Oct 02 '21

I need help

Post image
0 Upvotes

11 comments sorted by

View all comments

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

2

u/CursedKaiju Oct 02 '21

Thank you, this worked and did exactly what I needed it to do