Answer the question
In order to leave comments, you need to log in
For some reason, the unit says "Transform' does not contain a definition for 'left'?
In general, when I write player.transform.right, the code works, but when player.transform.left, for some reason, the unit writes "Transform' does not contain a definition for 'left' and no accessible extension method 'left' accepting a first argument of type 'Transform' could be found (are you missing a using directive or an assembly reference?" I am new to c#.
Here is the code:
using UnityEngine;
using System.Collections;
public class NewBehaviour : MonoBehaviour
{
public GameObject player;
public int speedRotation = 3;
public int speed = 5;
public int jumpSpeed = 50;
void Start()
{
player = (GameObject)this.gameObject;
}
void Update()
{
{
player.transform.position += player.transform.right * speed * Time.deltaTime;
}
}
}
Answer the question
In order to leave comments, you need to log in
transform.right Contains the value of the red (right) axis. To get the value of the "left" axis, you just need to take the right with a minus sign
Don't forget about the documentation: https://docs.unity3d.com/ScriptReference/Transform...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question