Hello,
I try to get input x and y value at the beginning and create and offset value,
after that in every update current x - offset x = movement vector
but i get an error . New to programming and any help is appreciated.
Assets/Scripts/Movementacc.cs(40,46): error CS1525: Unexpected symbol =' Assets/Scripts/Movementacc.cs(41,46): error CS1525: Unexpected symbol
=’
using UnityEngine;
using System.Collections;
public class Movementacc : MonoBehaviour {
public float speed;
public float speed1;
public float jumpforce;
private Rigidbody rb;
public AudioClip jumpSound;
private AudioSource SoundSource;
public GameObject ballParticle;
public float offSetX;
public float offSetY;
public float cX;
public float cY;
public void Calibrate()
{
Input.acceleration.x=offSetX;
Input.acceleration.y=offSetY;
}
void Start ()
{
rb = GetComponent<Rigidbody>();
SoundSource = GetComponent<AudioSource>();
Calibrate ();
}
void FixedUpdate ()
{
Input.acceleration.x-offSetX = cX;
Input.acceleration.y-offSetY = cY;
Vector3 movement2 = new Vector3(cX, 0.0f, cY);
rb.AddForce(movement2 * speed * Time.deltaTime);
Vector3 movement = new Vector3(Input.GetAxis("Horizontal"), 0.0f, Input.GetAxis("Vertical"));
rb.AddForce(movement * speed1 * Time.deltaTime);
}
void OnCollisionEnter (Collision col)
{
Vector3 jumpvec = new Vector3 (0.0f, 1.0f, 0.0f);
if(col.gameObject.name == "JumpPad")
{
rb.AddForce(jumpvec*jumpforce);
SoundSource.PlayOneShot(jumpSound,1.0f);
}
}
}