system
1
Hi everyone! I have been messing around with unity for quite a while now and a got a snag in my script for a mario galaxy type faux gravity.
Script :
//Attach this script to objects you want to be affected by FauxGravity
// this is the thing we're gravitationally attracted to
var attractor : FauxGravityAttractor;
// are we touching the surface?
var grounded : int;
function Start () {
rigidbody.WakeUp();
rigidbody.useGravity = false;
}
// obviously this is crude since we might want to be able to stand on (and jump off) random objects
// should probably filter based on tag in future
function OnCollisionEnter (c : Collision) {
if( c.gameObject.layer == 10 ){
grounded ++;
}
}
function OnCollisionExit (c : Collision) {
if( c.gameObject.layer == 10 && grounded > 0 ){
grounded --;
}
}
function FixedUpdate () {
if(attractor){
attractor.Attract(this);
}
}
@script RequireComponent(Rigidbody)
I keep getting an error saying---- The best overload for the method 'FauxGravityAttractor.Attract(FauxGravityBody)' is not compatible with the argument list '(FauxGravityBody2)'. OR---- Fauxgravity Attractor Does Not Denote A Valid Type.
could someone help me with this snag? Thanks!
_Petroz
2
It looks like you renamed your script from 'FauxGravityBody' to 'FauxGravtiyBody2'. Either rename it back or change the definition of the Attract function to take a FauxGravityBody2.