- Home /
Having a issue with Vector3.Slerp
I am currently trying to code recoil and watched a video to help me out but for some reason the .Slerp keeps coming up as a error
Heres the error:
There is no argument given that corresponds to the required formal parameter 't' of 'Vector3.Slerp(Vector3, Vector3, float)
Heres my code:
using UnityEngine;
public class Recoil : MonoBehaviour { //Rotations private Vector3 currentRotation; private Vector3 targetRotation;
 //Hipfire Recoil
 [SerializeField] private float recoilX, recoilY, recoilZ;
 //settings
 [SerializeField] private float snappiness, returnSpeed;
 void Start()
 {
     
 }
 void Update()
 {
     targetRotation = Vector3.Lerp(targetRotation, Vector3.zero, returnSpeed * Time.deltaTime);
     currentRotation = Vector3.Slerp(currentRotation, targetRotation * snappiness * Time.fixedDeltaTime);
     transform.localRotation = Quaternion.Euler(currentRotation);
 }
 public void RecoilFire()
 {
     targetRotation += new Vector3(recoilX, Random.Range(-recoilY, recoilY), Random.Range(-recoilZ, recoilZ));
 }
}
Answer by Captain_Pineapple · Mar 23 at 07:06 AM
Yes, as is most cases the error message tells you exactly what to do. Lerp and Slerp always expect a third argument which is a number between 0 and 1 that tells Unity what value to return.
Simple example in 1D:
  returnValue = FirstArg + (SecondArg - FirstArg)* ThirdArg;
Your code regarding Slerp just gives 2 argumets to Unity. The Interpolation value is missing. 
Your answer
 
 
             Follow this Question
Related Questions
Vector3.Slerp problem 1 Answer
Transforming slowly 1 Answer
move object and slow down near end 1 Answer
Slerp to make the right/left side face another object 2 Answers
Moving the player toward a direction 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
               
 
			 
                