- Home /
Question by
ItArth · May 03, 2021 at 01:27 AM ·
scripting problemsmoothvalue
Value increase or decrease smoothed
Im trying to smooth m_distance and increase or decrease it with Mouse ScrollWheel this is my current script but i dont know why is not working
screenshot-5.png
(13.4 kB)
Comment
Best Answer
Answer by Fariborzzn · May 03, 2021 at 01:47 AM
Hey @ItArth I think your issue is you make your change directly to m_distance so your change will not effect over time . your issue may be in is in this part :
float axis=UnityEngine.Input.GetAxis("Mouse ScrollWheel");
var distanceChange=m_distance-(axis*m_zoomSense);
distanceChange=Mathf.Clamp(distanceChange,minDistance,max);
m_distance=Mathf.SmoothDamp(m_distance,distanceChange,ref m_zoomVel,m_smoothness,999f,Time.deltaTime);
let me know if this works best regards Fariborz
This works perfects but i feel that distanceChange wheen i scroll up it's go more slower than when i go down.
I solved it thanks! its works perfect now i just change this line:
var distanceChange -= axis * m_zoomSens;