Slerp position not working? c#
Hi guys!
How are we all? :)
This is the code i have running in Update and is activated by ios touch...
theDistanceBetweenPlayerAndCamera = Vector2.Distance(theSliderDummy.transform.localPosition, theCamera.transform.localPosition);
and i have two lines of code, this is where my problem is:
theSliderDummy.transform.position = Vector3.Slerp(theSliderDummy.transform.position, (Camera.main.ScreenToWorldPoint(new Vector3(touch.position.x,touch.position.y,theDistanceBetweenPlayerAndCamera))), step);
//and...
theSliderDummy.transform.position = Vector3.Slerp(theSliderDummy.transform.position,(new Vector3(theCentralSpline.transform.position.x,theCentralSpline.transform.position.y,theCentralSpline.transform.position.z)), stepReturn);
It all works fine however the second lines .z position throws the object forward in space too much, how can i get it to be the same as the top line's .z position while keeping the touch.positions?
I suspect it has something to do with screen positions being different to actual world positions? If so, how do i fix this?
Hope that makes sense,
Cheers
Comment
Your answer
Follow this Question
Related Questions
Opening door script in C# 3 Answers
Player's rotation gets stuck when pressing two movement keys together 0 Answers
Interpolated movement in a circle 1 Answer
Slerp rotation issue when calling a lot 0 Answers