Jump to content

  • Log In with Google      Sign In   
  • Create Account

Collision for tangential movement in unity


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 Neoshaman   Members   -  Reputation: 170

Like
0Likes
Like

Posted 16 June 2013 - 01:51 PM

I wonder what you guy would do for a cheap replacement of character controller in unity.

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)

Currently my code is this one, with sweeptest(): http://docs.unity3d.com/Documentation/ScriptReference/Rigidbody.SweepTest.html

 

private void UpdateSurfacePosition()
{
Ray//origine, direction
ground_check_ray = new Ray( gameObject.transform.position, -gameObject.transform.up);// * (Momentum.magnitude + 1));
RaycastHit
raycast_result;
Rigidbody
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;
i++;
}
raycast_result.normal = raycast_result.normal.normalized;
}
else
{
onGround = false;
}


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


if ( onGround )
{
Vector3
next_position;

//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;
}
else//onAir
{
//if forward close to dot.Y = abs(1) choose -up if 1 and up if -1
UpdateMoveOrientation( gameObject.transform.forward, raycast_result.normal );
}
}

 


>>>>>>>>>>>>>>>be goodbe evilbut do it WELL>>>>>>>>>>>>>>>

Sponsor:

#2 Neoshaman   Members   -  Reputation: 170

Like
0Likes
Like

Posted 23 June 2013 - 08:58 PM

http://forum.unity3d.com/threads/142375-The-limitations-of-the-physics-API-and-creating-a-character-controller

I would advise any serious person to make complex game with unity ... it does not handle gameplay collision properly


>>>>>>>>>>>>>>>be goodbe evilbut do it WELL>>>>>>>>>>>>>>>




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS