- Home /
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!
Answer by _Petroz · Nov 30, 2010 at 12:46 AM
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.
Glad to hear it worked, please mark this as the correct answer to close this question.
Your answer
Follow this Question
Related Questions
Can someone help me fix my Javascript for Flickering Light? 6 Answers
Setting Scroll View Width GUILayout 1 Answer
C# or UnityScript 4 Answers
Learn Scripting Easy? 5 Answers
Array problem -3 Answers