using System.Collections.Generic;
using UnityEngine;
public class PipeMoveScript : MonoBehaviour
{
public float moveSpeed = 5f;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
transform.position = transform.position + (Vector3.left + moveSpeed * Time.deltaTime);
}```
it gives me error in the line where i try to add something to transform.position and i am kinda a beginner so i dont know how to fix, please help me
2 Answers
2I think you probably meant to multiply Vector3.left by moveSpeed, not add them together, right?
nevermind i think i’ve solved
Ideally you click the checkmark on one of the replies to identify which post was the solution to your problem. if you solved the problem yourself, you can make your own reply and then mark that as the solution.
– dstears
like i'm making a flappy bird game, following a tutorial and he do like that, this is the code which make an object make to the left, anyway now i'll try by multiplying it by moveSpeed but please if you know any solutions to add that please send it :D
– LoneC0derVector3 is a vector and moveSpeed * Time.deltaTime is a scalar. You cannot add a vector and a scalar together because it doesn't make sense. You can multiply a vector by a scalar to change the magnitude of the vector, this is often how movement is done in implementations like yours.
– dstearsalso have the same problem but solved it by adding unityEngine.Vector3.left so the error will go away ANSWER -------------------------------- transform.position += UnityEngine.Vector3.left * moveSpeed ; ----------------------------
– SazeKing