B
B
BadCats2016-11-30 12:41:12
C++ / C#
BadCats, 2016-11-30 12:41:12

Bug in code in Unity 3d?

Hello everyone, actually on the line

PosZ = PosZ + speed * Time.deltaTime * transform.forward;//к текущей позиции добавили в направлении вперед немного))

an error occurs
Error CS0019 Operator "+" cannot be applied to an operand of type "float" and "Vector3"
and another Error Cannot implicitly convert type
`UnityEngine.Vector3' to `float
' and - i.e. both operands are of type float , but for some reason the studio thinks that one of them is of type UnityEngine.Vector3 I can't figure out why. Here is a link to the full script: https://drive.google.com/file/d/0B605djhCYgF_WUItQ...
float PosZ = (float)hero.transform.position.z;
public float speed=2;

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
GavriKos, 2016-11-30
@BadCats

transform.forward is actually a Vector3. Multiplying a vector by a number gives a vector. Those. the entire right side (speed * Time.deltaTime * transform.forward) results in a vector.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question