Question by
ProbieProbie · Aug 18, 2017 at 02:38 PM ·
scripting problem
(PLS HELP) Script error while making script for character to stay on moving platform.
I am probie, sry if i ask stupid things. I animated platform and i added script to collider, but i get error. Assets/Script/movingplatform.cs(1,9): error CS1525: Unexpected symbol gameObject', expecting
class', delegate',
enum', interface',
partial', or `struct'
Here is the code:
private GameObject target=null;
private Vector3 offset;
void Start(){
target = null;
}
void OnTriggerStay(Collider col){
target = col.gameObject;
offset = target.transform.position - transform.position;
}
void OnTriggerExit(Collider col){
target = null;
}
void LateUpdate(){
if (target != null) {
target.transform.position = transform.position+offset;
}
}
Thanks in advance.
Comment
Your answer
