Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Scripting problem

Discussion in 'Scripting' started by Neo_maister, May 23, 2015.

  1. Neo_maister

    Neo_maister

    Joined:
    Apr 16, 2015
    Posts:
    14
    Code (JavaScript):
    1. #pragma strict
    2.  
    3. var playeracceleration : float = 7.5;
    4. var cameraobject : GameObject;
    5.  
    6. function Update ()
    7. {
    8.   transform.rotation = Quaternion.Euler(0, cameraobject.GetComponent(MouseLook).CurrentYRotation);
    9.   GetComponent.<Rigidbody>().AddRelativeForce(Input.GetAxis("Horizontal")*playeracceleration * Time.deltaTime, 0, Input)(Input.GetAxis("Vertical")*playeracceleration * Time.deltaTime);
    10. }
    i got 2 error compiles in this script:
    -BCE0023: No appropriate version of 'UnityEngine.Rigidbody.AddRelativeForce' for the argument list '(float, int, System.Type)' was found.
    -BCE0023: No appropriate version of 'UnityEngine.Quaternion.Euler' for the argument list '(int, float)' was found.

    can you guys help me to solve it?
     
  2. ZHH TMW

    ZHH TMW

    Joined:
    Dec 10, 2014
    Posts:
    4
    I'm no expert and not sure what you are trying to do but it should look something like this.

    Code (JavaScript):
    1. var acceleration:float = 7.5;
    2. var rigidbodyA:Rigidbody;
    3. var x:float;
    4. var y:float;
    5.  
    6. function Start () {
    7.     rigidbodyA = GameObject.Find("Cube").GetComponent.<Rigidbody>();
    8.     x = Input.GetAxis("Horizontal")*acceleration * Time.deltaTime;
    9.     y = Input.GetAxis("Vertical")*acceleration * Time.deltaTime;
    10. }
    11.  
    12. function OnMouseDown () {
    13.      transform.rotation = Quaternion.Euler(10, 0, 0);
    14.        rigidbodyA.AddRelativeForce(Vector3(x, y, 0), ForceMode.Acceleration);
    15. }
    http://docs.unity3d.com/ScriptReference/Quaternion-eulerAngles.html