Question by
Captain_Brash · Apr 25, 2016 at 12:03 AM ·
c#unity 5physicsvector3
getting two errors and none of the fixes ive found online work or are relevant to my code CS0019 and CS1061 (full errors below)
Error CS0019 Operator '' cannot be applied to operands of type 'Vector3' and 'Vector3'
AddVel = GetComponent().velocity AddVel;
Error CS1061 'Vector3' does not contain a definition for 'AddRelativeForce' and no extension method 'AddRelativeForce' accepting a first argument of type 'Vector3' could be found (are you missing a using directive or an assembly reference?)
AddVel.AddRelativeForce(Vector3.forward * thrustVal);
dont judge me for the rest of my code. :) its not finished yet, im part way through changing the general format and variables round. just want to get these errors fixed. thanks. i know the second one is to do with deprecated use of rigidbody but i cant fix it
using UnityEngine;
using System.Collections;
public class ShipControl : MonoBehaviour
{
public float AmbientSpeed = 100.0f;
public float RotationSpeed = 200.0f;
private ShipControl PlayerFighter;
public Rigidbody AddVel;
void Start()
{
AddVel = GetComponent<Rigidbody>();
}
void FixedUpdate()
{
Quaternion AddRot = Quaternion.identity;
float pitch = 0;
float pitchVal = 0;
float roll = 0;
float rollVal = 0;
float yaw = 0;
float yawVal = 0;
float thrust = 0;
float thrustVal = 0;
roll = Input.GetAxis("Roll") * (Time.deltaTime + rollVal);
pitch = Input.GetAxis("Pitch") * (Time.deltaTime + pitchVal);
yaw = Input.GetAxis("Yaw") * (Time.deltaTime + yawVal);
thrust = Input.GetAxis("Throttle") * (Time.deltaTime * thrustVal);
AddRot.eulerAngles = new Vector3(-pitch, yaw, -roll);
Vector3 AddPos = Vector3.forward;
Vector3 AddVel = Vector3.forward;
AddPos = GetComponent<Rigidbody>().rotation * AddPos;
AddVel = GetComponent<Rigidbody>().velocity * AddVel;
//Vector3 AddVel = new Vector3.velocity(moveHorizontal, 0.0f, moveVertical);
//AddVel = GetComponent<Rigidbody>();
AddVel.AddRelativeForce(Vector3.forward * thrustVal);
GetComponent<Rigidbody>().AddRelativeForce(AddVel);
GetComponent<Rigidbody>().rotation *= AddRot;
GetComponent<Rigidbody>().velocity = AddPos * (Time.deltaTime * AmbientSpeed);
}
}
Comment