Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I wonder what you guy would do for a cheap replacement of character controller in unity. I try a bunch of implementation and they don't work at all, what I'm doing wrong?

I'm trying to make a game with megadrive's sonic pinball physics, think (technically) about mario galaxy meet tony hawk with sonic's high speed. Currently I use a simple raytracing, but I'm looking to listen collision around the sphere collider.

In my case i tried:

  1. Rigidbody turn the game in a slide show, Intel atom n455 for the win (actually I like the limitation so it can run on most machine).
  2. Kinetic body don't collide with scenery (don't listen collision).
  3. Character controller don't rotate.
  4. Sweeptest() and SweepTestAll() but walls and inward curve fails dramatically. + it does not work with the flash preview of unity 3.x

I want to be able to move the character according to tangent of arbitrary complex volumes. For example, taking slope change higher than 90° and leave the case handling with special case code (for example stopping at a wall or falling down a cliff)

What should I do to meet the requirement with good performance?

Currently my code is this one, with sweeptest() which doesn't work:

private void UpdateSurfacePosition()
        Ray//origine, direction
            ground_check_ray = new Ray( gameObject.transform.position, -gameObject.transform.up);// * (Momentum.magnitude + 1));
            rigid_body = gameObject.rigidbody;

        rigid_body.detectCollisions = false;
        rigid_body.isKinematic = true;

        bool onGround;// =
            //Physics.Raycast( ground_check_ray, out raycast_result );//ray, hit
            //rigid_body.SweepTest(-gameObject.transform.up, out raycast_result);//direction, hit, distance

        raycast_result = new RaycastHit();
        RaycastHit[] contacts = rigid_body.SweepTestAll(-gameObject.transform.up);

        rigid_body.SweepTest(-gameObject.transform.up, out raycast_result);

        if (contacts.Length > 0)
            onGround = true;
            int i=0; while (i != contacts.Length)
                raycast_result.normal += contacts[i].normal;
            raycast_result.normal = raycast_result.normal.normalized;
            onGround = false;

        debug1 = "Normal > " + raycast_result.normal.ToString()
            + " Position > "+ raycast_result.point.ToString()
                //+" transform > "+
                + " Contact > " + contacts.Length

        if ( onGround )

            //UpdateOrientation( gameObject.transform.forward, raycast_result.normal );

            UpdateMoveOrientation( gameObject.transform.forward, raycast_result.normal );   
            next_position = GetNextPosition( raycast_result.point );
            rigid_body.MovePosition( next_position );

            //ground_direction = raycast_result.normal;
            //if forward close to dot.Y = abs(1) choose -up if 1 and up if -1
            UpdateMoveOrientation( gameObject.transform.forward, raycast_result.normal );
share|improve this question
I'd get a complete Char. Con. from the asset store, or ask on I read this before going to bed, I will think about it when I wake up, the cc I used from the asset store, had a function that slowed the character if the slope was steep. I think I paid $70 for this bundle – Mikolaj Marcisz Jun 17 '13 at 3:09
I wish I could spend money but i'm totally broke right now, even the net is provided by free wifi public spot! However I'll try to ask unity answer, I always forget about them. However I don't want "heightfield" controller, It's more like mario galaxy (or the recent sonic lost world on wii U) I can do those perfectly. Slope isn't a problem for movement, the problem is proper collision at any angle and any number of contacts. But thank you to take the time to look at it, I wait with anticipation any advice or observation you could have that would unlock my situation. – user29244 Jun 17 '13 at 3:26
OKAY! Turn out that unity is shit for collision resolution and confuse physic for gameplay ... It's not good for making hi quality game at all.… – user29244 Jun 24 '13 at 2:56
Get Havok, it has a SWEET collision engine. Though you might have problems with licensing. I think it might let you do the thing ;) – Mikolaj Marcisz Jun 24 '13 at 3:19
But i'm using unity :'(, but my problem is performance right now, i cannot emulate a simpler resolution as I don't have the necessary tool. It was solved with rigid body but at the expense of running a slide show ... I made of a rant for sure, I have been working on this simple thing (relatrive cam control mostly) for 3 years, fighting gimbal lock, quaternion and finally hairy ball ... – user29244 Jun 25 '13 at 1:09

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.