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