Hi there,
While scripting how can we know if and object is moving or not ?
the solution I found is that to see the difference between positions cheked at the Update function and the FixedUpdate function, the problem is that I dont want my object to stop moving (its moving due to an AddForce function) ! (it actually can stop cauz its an object gliding on a collider with Ice material and there is a slope sometimes), and according to that I apply a harder Addforce for it to move when detecting the difference but its not slerp
Here is my c# script
[Cheking the difference between positions inside the update function is the same]
using UnityEngine;
using System;
using System.Collections;
public class mvtScript : MonoBehaviour {
public bool isGrounded = false;
public float advanceForce = 35F;
public float fallForce = -30F;
public float density = 1.5F;
public Vector3 rotPoz;
public float vitesseX;
public float point;
void Awake()
{
point = transform.position.x;
}
void Update()
{
if(point > transform.position.x)
{
Vector3 temp = transform.position;
temp.x=point;
transform.position=temp; // ensure that the GO wont go back
this.rigidbody.AddForce(200,0,0);
}
point=transform.position.x;
}
void FixedUpdate ()
{
if (Input.GetKey("down"))
{
this.rigidbody.AddForce(0, fallForce, 0);
}
if(isGrounded)
{
this.rigidbody.AddForce(advanceForce,0,0);
fallForce=-1F;
}
if(!isGrounded)
fallForce=-90F;
}
}
And as I said, this gives me non slerp mouvement, and its not what I exactly need ! Any suggestions ?