Hello, I am verry new to Unity. I used GameMaker Studio (GML) for a few years, but C# is new to me. I am busy watching tutorials and adding some extra stuff to it myself to learn the language. But I am stuck. This is what I have:
using UnityEngine;
using System.Collections;
public class PlayerMovement : MonoBehaviour {
private Vector3 input;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
input = new Vector3(Input.GetAxis ("Horizontal"),0,Input.GetAxis ("Vertical"));
rigidbody.AddForce(input*20);
if (Input.GetKey(KeyCode.Space))
{
transform.position.y += 40;
}
}
}
But when I try to run this I get an error that I cannot modify a value type return value of ‘UnityEngine.Transform.postion’.
How can I solve this?
using UnityEngine;
using System.Collections;
public class PlayerMovement : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
transform.position = new Vector3(Input.GetAxis ("Horizontal"),0,Input.GetAxis ("Vertical"));
if (Input.GetKey(KeyCode.Space))
{
transform.position.y += 40;
}
}
}