- Home /
Make the character motor script gravity change directions?
So the default character motor script takes a float for the gravity and uses that to move the character down on the y-axis. How would I modify this to accept a Vector3 instead so I can move it in various directions(z,y,z) without breaking the script? The script does a lot of very helpful things and otherwise is perfect, so I don't want to have to rewrite it for this one addition and I don't fully understand its workings enough to write my own.
I did a quick skim of the Character$$anonymous$$otor.js script. I saw no easy hack to make this change. There were a number of areas that assume a standard movement on the 'XZ' with gravity along the 'Y'.
That's unfortunate, also I have discovered you can't actually rotate the character controller collider, so I wouldn't be able to use a character controller anyway. What solutions are there to doing character movement; other than a rigidbody or character controller?
I'm not an expert on character technology. You could directly move the transform and use Raycasting to detect collisions.
I don't know your game concept, but might it be possible to rotate the world (or at least the camera) and not the character? From the player's perspective it could look the same.
Hmmm... I found this. Which may do the trick, however I don't use c#, do you know what the js equivalent would be?
Based on some comments made by someone with more $$anonymous$$arma than I had at the time, eight months ago I decided not to do any more Javascript <-> C# translations except for code I posted for an Answer. But I decided I would help anyone that made a good-faith effort at a translation finish their script. This is not a slap at you for asking, but I feel that Javascript <-> C# translation is a skill very helpful to interacting on this list, plus 90% of code can be translated knowing only a handful of differences between the two languages. Here is a reference that helped me when I started out with Unity:
http://answers.unity3d.com/questions/12911/what-are-the-syntax-differences-in-c-and-javascrip.html
I know that others active on the list don't have the stance with respect to translation, so If you post your request as a new question, you are likely to get an answer.