- Home /
Question by
CoolBusGaming · Aug 19, 2017 at 08:13 PM ·
programmingproblem during runtimeconsole errorsscrpting
Primary constructor body is not allowed?!
Please help me with my program! Whenever I try to run it it says "Primary constructor body is not allowed" Can someone fix it. Thanks!
using UnityEngine;
[RequireComponent(typeof(Rigidbody))] public class PlayerMotor : MonoBehaviour {
private Vector3 velocity = Vector3.zero;
private Rigidbody rb;
void Start ()
{
rb = GetComponent<Rigidbody>();
}
// Gets a movement vector
public void Move (Vector3 _velocity)
{
velocity = _velocity;
}
// Run every physics iteration
void FixedUpdate ()
{
PerformMovement();
}
//Perform movement based on velocity variable
void PerformMovement ();
{
if (velocity != Vector3.zero)
{
RenderBuffer.MovePosition(RenderBuffer.position + velocity * Time.fixedDeltaTime);
}
}
}
Comment
What is RenderBuffer? Is that really what you want to be moving? Other than that this script is fine.
Answer by Kauppasarvi · Aug 20, 2017 at 10:10 AM
Issue is on line 22,
void PerformMovement ();
shouldn't have semicolon
;
Also, you probably want to call rb.MovePosition, instead of RenderBuffer.MovePosition.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
i need help in threading programation in unity 3d 0 Answers
Console Error but not showing 3 Answers