Gravity Stops working when I add this player script:

I have gravity in the on a player via a rigidbody ( I tried the same with a character controller but it caused the same issue).
It works fine when its applied to the player by its self, but then when I attach the player script to it, the gravity stops working, and I assume the whole rigidbody does.
Here is the code if you can please help me , iv been looking at this for hours

using UnityEngine;
using System.Collections;

public class charsc : MonoBehaviour {

	private Animator pAn;

	private Vector3 tempPos;
	private Vector3 tempTrans;

	private CharacterController cntrl;

	public float js = 20f;
	public float grav = 1f;

	// Use this for initialization
	void Start () {

		pAn = gameObject.GetComponent<Animator>();
		tempPos = transform.position;

		cntrl = GetComponent<CharacterController> ();
	}
	
	// Update is called once per frame
	void Update () {

		transform.position = tempPos;
		//transform.Translate = tempTrans;

		gTouch ();
	}

	void FixedUpdate(){
	}

	public void gTouch(){

		for(int i = 0; i < Input.touchCount; i++)
		{
			Touch touch  = Input.GetTouch(i);
			
			if(touch.phase == TouchPhase.Began)
			{
				if(touch.position.x<(Screen.width/2)){
					moveR();
				}
				if(touch.position.x > (Screen.width/2)){	
				}
			}
			if(touch.phase == TouchPhase.Stationary){
				if(touch.position.x<(Screen.width/2)){
					moveR();
				}
				if(touch.position.x > (Screen.width/2)){
				}
			}
			if(touch.phase == TouchPhase.Ended)
			{
				
			}
		}
	}

	public void moveR(){
		tempPos += (transform.forward * 0.2f)*Time.deltaTime;
	}

	public void moveL(){
		tempPos.x--;
	}

	private void RunTouch(){
	}

}

The problem is this line in your Update() function: transform.position = tempPos;

That line is setting the object’s position back to it’s current position every frame (because tempPos is initialized to the object’s starting position). And since you are keeping it at it’s current position you’re not actually letting the Gravity do anything.

So what I’d suggest is using tempPos to store the amount that you need to move the object on that frame (so 0,0,0 if you don’t want to move it on that frame). Then just do this:

transform.position += tempPos; // move it by amount tempPos
tempPos = Vector3.zero; // set tempPos back to 0 since you've done the movement for this frame now