- Home /
tell me whats wrong with this lerp
im getting this error Assets/Scripts/time.cs(42,57): error CS1502: The best overloaded method match for UnityEngine.Vector3.Lerp(UnityEngine.Vector3, UnityEngine.Vector3, float)' has some invalid arguments and this one Assets/Scripts/time.cs(42,57): error CS1503: Argument
#1' cannot convert UnityEngine.Transform' expression to type
UnityEngine.Vector3'
using UnityEngine;
using System.Collections;
public class time : MonoBehaviour {
public float timescale = 1;
Transform MyTf;
float speed = 1f;
float dist;
float timestart;
float length;
float frac;
public Transform pos;
public Transform pos1;
// Use this for initialization
void Start () {
MyTf = transform;
}
// Update is called once per frame
void Update () {
length = Vector3.Distance (pos.position, pos1.position);
dist = (Time.time - timestart)* speed;
frac = dist / length;
Time.timeScale = timescale;
if(Input.GetKeyDown("2")){
timescale = 1;
Time.fixedDeltaTime = 1f * 0.02f;
}
if(Input.GetKeyDown("1")){
timescale = 0.15f;
Time.fixedDeltaTime = 0.15f * 0.02f;
}
if(timescale == 0.15f){
if(Input.GetKeyDown("q")){
timescale = 1;
Time.fixedDeltaTime = 1f * 0.02f;
MyTf.position = Vector3.Lerp(pos , pos1 , frac);
}
}
if(timescale == 0.15f){
if(Input.GetKeyDown("e")){
timescale = 1;
Time.fixedDeltaTime = 1f * 0.02f;
}
}
}
}
i would very much appreciate any help thanks
Comment
Best Answer
Answer by robertbu · May 21, 2014 at 10:35 PM
Vector3.Lerp's first two parameters are Vector3s. You are passing transforms. Change line 42 to:
MyTf.position = Vector3.Lerp(pos.position, pos1.position, frac);
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Weapon Movement Freezing 0 Answers
Smooth translation 2 Answers
Vector3.Lerp Only working once 1 Answer
Vector3 Lerp using Time.deltaTime? 3 Answers