so i have been following a tutorial, but i came accros some errors
Assets/scripts/PlayerMovement.cs(31,64): error CS0120: An object reference is required to access non-static member `UnityEngine.Transform.position’
Assets/scripts/PlayerMovement.cs(31,25): error CS1502: The best overloaded method match for `UnityEngine.Object.Instantiate(UnityEngine.Object, UnityEngine.Vector3, UnityEngine.Quaternion)’ has some invalid arguments
Assets/scripts/PlayerMovement.cs(31,25): error CS1503: Argument #2' cannot convert
object’ expression to type `UnityEngine.Vector3’
Assets/scripts/PlayerMovement.cs(32,31): error CS0120: An object reference is required to access non-static member `UnityEngine.Transform.position’
now the code:
using UnityEngine;
using System.Collections;
public class PlayerMovement : MonoBehaviour {
public float movespeed;
private float maxSpeed = 15f;
private Vector3 spawn;
private Vector3 input;
public GameObject deathparticles;
// Use this for initialization
void Start () {
spawn = transform.position;
}
// Update is called once per frame
void Update () {
Rigidbody rigidbody = GetComponent<Rigidbody>();
input = new Vector3 (Input.GetAxisRaw ("Horizontal"), 0, Input.GetAxisRaw ("Vertical"));
if (rigidbody.velocity.magnitude < maxSpeed) {
rigidbody.AddForce(input * movespeed);
}
}
void OnCollisionEnter(Collision other)
{
if (other.gameObject.tag == "enemy")
{
Instantiate (deathparticles, Transform.position, Quaternion.identity);
Transform.position = spawn;
}
}
}
Thanks in advance