I have created a project consisting of a sphere that needs to stick to the inner surface wall of a tunnel. So i have attached a script to the sphere:
using UnityEngine;
using System.Collections;
public class GravityOnBall : MonoBehaviour
{ public float GravX;
public float GravY;
public float Mult;
void Start () {
Physics.gravity = new Vector3(GravX * Mult, GravY * Mult, 0);
}
}
What I want to do is to assign the x and y coordinate values of the transform position of gameobject which is the sphere to the variables GravX and GravY respectively.
Please help me to write a script for the above mentioned task.