Hi all,
I must do a game in my 3D animation formation,
I currently am doing a special sidescroller and I would like my character to be able to walk (stick) under some specific platform. And for this, I`d like to replace the “run” function since its no use in my game. (so pressing Ctrl would stick my character under the platform if he is in contact with it)
The thing is, I’m a big 0 in javascripting, I’m trying to learn asap, but I wont make it in time for when the project is due. :?
I’m currently using the 2Dgameplay tutorial script to build my level in, with unity 2.6. If anyone would show me how, with or without explanation if you dont have time, that would be GREATLY appreciated !
And if anyone have any good javascript tutorial that would be nice too, all the ones I find or more web-based…
Many thanks !!
please post your movement-related code. many people don’t have time to look up where you got the tutorial from or are simply too lazy.
There it is
if you need something else to disable the running, please ask.
It’s actualy the first thing i’m doing in the game, beside some testing, so its some preset of the tutorial again.
Beside the original sidescroller mechanic (dunno if you need to know that, but in case…) I’m later gonna make a trigger that the camera will change position and so, I will need to create a second set of control for that position. (Guessing I could use the second set used for joystick and stuff in the input settings. I am still searching info on this…)
Thanks a lot for the help
getting better in java ! 
380811–13150–$platformercontroller_109.js (10.9 KB)
After trying to customize the “run” fonction a little bit myself, I realized that in order to make the appropriate change (run → “sticky walk”) you need the animation script too.
So here it is.
I’m still trying to figure out how it could work as a script (walking under platform) but beside a total new script I’ve no idea… 
Only solution I have so far, is to create a secondary gravity that’d affect only my character and in specific boundaries (to prevent using it everywhere)
Dunno if that one can help you/is possible.
Or parenting him to a capsule (while holding fire1) wich I could restraint it’s movement.
Hoping for tips / help from you guys ! 
Thanks a lot !
382086–13189–$platformercontroller_146.js (10.9 KB)
382086–13190–$platformerplayeranimation_177.js (2.34 KB)
You can get the normal of the surface underneath the character by doing a raycast in the character’s local downward direction. (The raycast returns a RaycastHit object that contains a field for the normal.) You can make the character align itself with the normal (ie, stand “upright” on the surface) using Quaternion.FromToRotation:-
var hit: RaycastHit;
if (Physics.Raycast(transform.position, -transform.up, hit)) {
transform.rotation *= Quaternion.LookRotation(Vector3.up, hit.normal);
}
You should also handle the character’s movements using its local axes. For example, use transform.forward for the direction of motion and -transform.up for gravity. Using these techniques, you should get the effect of the character following the surface and moving relative to it. However, it might take a bit of work to get the effect just the way you want it, since it can be quite complicated.
So Basically, I must create a double condition ; the raycastHit + input button
to trigger the transform.
I’ve made some tests, and my character dont do anything when colliding with a platform, and is ‘standing’ sideway in the floor, in normal conditions. Is that alright ?
(Using the awesome Andeeee same script.)