Calibration of accelerometer with offset


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()

	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( == "JumpPad")


You used “=” symbol in a wrong way, because it assigns the right side value to the left side. If you use it to assign the left side value to the right side, it will make no sense for the compiler.

You should write:
cX = Input.acceleration.x-offSetX ;
cY = Input.acceleration.y-offSetY ;


I just learned another thing and had another error there " Input.acceleration.x=offSetX;
nput.acceleration.y=offSetY;" swapped values and code doesnt give anymore errors thanks :).