error unexpected symbol'quaternion',error primary constructor body is not allowed,error ; expected i have a lot of errors please help gotta project due in some time and got to iron out some bugs
using UnityEngine; using System.Collections;
public class RecievedMovement : MonoBehaviour {
Vector3 newposition;
public float speed;
public float walkRange;
public GameObject graphics;
void Start() {
newposistion = this.transfrom.position;
}
void Update() {
if (Vector3.Distance(newposistion, this.transform.position) > Walkrange) {
this.transform.position = Vector3.MoveTowards(this.transform.position, newposition, speed * Time.deltaTime)
Quaternion transRot = Quaternion.LookRotation(newposition - this.transform.position, Vector3.up);
graphics.transform.rotation = Quaternion.Slerp(transRot, graphics.transform.rotation, 0.2f);
}
}
{PunRPC}
public void RecievedMove (Vector3 movePos) {
newposition = movePos;
}
Answer by Landern · Apr 19, 2017 at 05:41 PM
Your curly braces are out of order. The method RecievedMove is outside of the class (RecievedMovement), attributes that decorate Classes/Methods/Properties/etc use Square Brackets and not curly braces.
The class should look like:
using UnityEngine;
using System.Collections;
public class RecievedMovement : MonoBehaviour
{
Vector3 newposition;
public float speed;
public float walkRange;
public GameObject graphics;
void Start()
{
newposistion = this.transfrom.position;
}
void Update()
{
if( Vector3.Distance(newposistion, this.transform.position) > Walkrange )
{
this.transform.position = Vector3.MoveTowards(this.transform.position, newposition, speed * Time.deltaTime)
Quaternion transRot = Quaternion.LookRotation(newposition - this.transform.position, Vector3.up);
graphics.transform.rotation = Quaternion.Slerp(transRot, graphics.transform.rotation, 0.2f);
}
}
[PunRPC]
public void RecievedMove(Vector3 movePos)
{
newposition = movePos;
}
}
Also not including the full error including line numbers for ALL of your issues isn't helpful at all.
error CS1525 Unexpected Symbol: 'Quarternion' error CS9010: Primary constructor body is not allowed error CS1002 ; expected using UnityEngine; using System.Collections;
public class Recieved$$anonymous$$ovement : $$anonymous$$onoBehaviour {
Vector3 newposition;
public float speed;
public float walkRange;
public GameObject graphics;
void Start() {
newposistion = this.transfrom.position;
}
void Update() {
if (Vector3.Distance(newposistion, this.transform.position) > Walkrange) {
this.transform.position = Vector3.$$anonymous$$oveTowards(this.transform.position, newposition, speed * Time.deltaTime)
Quaternion transRot = Quaternion.LookRotation(newposition - this.transform.position, Vector3.up);
graphics.transform.rotation = Quaternion.Slerp(transRot, graphics.transform.rotation, 0.2f);
}
}
{PunRPC}
public void Recieved$$anonymous$$ove (Vector3 movePos) {
newposition = movePos;
}
}
Your answer
Follow this Question
Related Questions
Displaying Text on Touch Event 0 Answers
Having trouble moving a GameObject to another scene and Transform it to a different position 0 Answers
unity visual studios not working properly 0 Answers
Finishing up my 2D quiz game [Last Problem] 0 Answers
Is there any way to increase score with UI when I destroy an object? 0 Answers