c# - How to fix the below error in the simple chaser program in unity 3d? -


i new unity 3d , c sharp. designing program in sphere chasing cube . tried it's showing error.

error in console :

assets/chaserr.cs(8,40): error cs0019: operator `-' cannot applied operands of type `unityengine.transform' , `unityengine.vector3' assets/chaserr.cs(11,38): error cs0019: operator `+' cannot applied operands of type `unityengine.vector3' , `float' assets/chaserr.cs(11,27): error cs1502: best overloaded method match `unityengine.transform.translate(unityengine.vector3)' has invalid arguments assets/chaserr.cs(11,27): error cs1503: argument `#1' cannot convert `object' expression type `unityengine.vector3' 

chaserr.cs

using unityengine; using system.collections;  public class chaserr : monobehaviour {     public transform target;     float speed = 8;     void update () {         vector3 displacement = target - transform.position;         vector3 direction = displacement.normalized;         vector3 velocity = direction * speed;         transform.translate (velocity + time.deltatime);     } } 

move.cs

using unityengine; using system.collections;  public class move : monobehaviour {     float speed = 10;     void update () {         vector3 input = new vector3 (input.getaxisraw ("horizontal"), 0, input.getaxisraw ("vertical"));         vector3 direction = input.normalized;         vector3 velocity = direction * speed;         vector3 moveamount = velocity * time.deltatime;         transform.translate (moveamount);      } } 

if want other other information please please comment..

instead of

vector3 displacement = target - transform.position;

use

vector3 displacement = target.position - transform.position; 

and

instead of

velocity + time.deltatime

use

velocity * time.deltatime


Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -