Reputation: 45
I am trying to do something, and I get this error:
Cannot implicitly convert type float to UnityEngine.transform
code:
private Transform EndPos;
EndPos = transform.position.x + 40f;
transform.position = Vector3.MoveTowards(transform.position, EndPos, moveSpeed * Time.deltaTime);
Thank you for your help
Upvotes: 0
Views: 674
Reputation: 19
Instead of doing "EndPos = transform.position.x + 40f;" Change the "X" of EndPos (EndPos.position.x) and then use it.
Upvotes: 0
Reputation: 543
EndPos
is type Transform
. You are trying to set it to transform.position.x
which is type float
.
I think what you are trying to do is:
EndPos.position = transform.position + (Vector3.right * 40f);
This sets EndPos
40 units to the right of transform
's current position.
Upvotes: 1