x


Faux Gravity problem?

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!

more ▼

asked Nov 30 '10 at 12:29 AM

Sean_The_Ripper gravatar image

Sean_The_Ripper
43 8 10 15

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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.

more ▼

answered Nov 30 '10 at 12:46 AM

_Petroz gravatar image

_Petroz
3.6k 27 35 57

Thanks a lot! It Worked! I appreciate your help!

Nov 30 '10 at 01:52 PM Sean_The_Ripper

Glad to hear it worked, please mark this as the correct answer to close this question.

Nov 30 '10 at 11:24 PM _Petroz
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x5093
x3464
x3340
x20
x10

asked: Nov 30 '10 at 12:29 AM

Seen: 1279 times

Last Updated: Nov 30 '10 at 11:29 PM