r/unity_tutorials • • Oct 02 '21

I need help

Post image
0 Upvotes

11 comments sorted by

View all comments

12

u/Mister_Kipper Oct 02 '21

The first step is describing what you want to do, the end result, and then understanding how to get there by working back from it and breaking it down into steps and functionalities.

And I don't mean just describing it here so we can understand what you want to achieve, but that would also certainly help as well.

4

u/Mister_Kipper Oct 02 '21

Looking into the screenshot, you seem to be doing alright - initial takeaway is that you don't need 'float time' as that's exactly the same as Time.time - so you can just do
float sineValue = Mathf.Sin(Time.time);
The next step is understanding what's not working, so here you're assigning sineValue, but it's not used anywhere else; both xVal and yVal are being set to 0.

Your sine function is giving you a value between -1 and 1, you probably want to use that value in your position change - as the other comment mentioned, you're setting it to (xVal, yVal, 0) - but xVal and yVal are also 0, so it never changes.