Hello Guest

Author Topic: Collision Problem  (Read 5115 times)

TinSleeves

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 18
    • View Profile
Collision Problem
« on: December 21, 2012, 11:39:08 pm »
Hi Guys,
I'm having a slight problem with collision, for some reason my player sprite doesn't seem to collide with my tilemap where it should. Take a look at the attached image to see what I mean.



Any idea why this would be happening? I'm using a standard orthographic camera

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Collision Problem
« Reply #1 on: December 22, 2012, 08:48:26 am »
Yes, it looks like the penetration threshold is too low, or your objects are too small for default settings. Edit > Project Settings > Physics.

Either that, or increase the physical size of your objects (change ortho size) in the camera and the sprite collection.

TinSleeves

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: Collision Problem
« Reply #2 on: December 22, 2012, 01:03:05 pm »
Thanks for the quick reply Unikron, you rule!

I changed the 'min penetration for renal' field to 0.001 which solved the problem.

I followed the 'Creating A Sprite In The Editor' tutorial and set the ortho camera size to 1.0. Will having sprites this small cause problems later? Either with collision, crispness of the visuals or anything else?

Also another quick question about that tutorial (there's always more questions :-[) it mentions setting the target resolution 960x640 where about do i do this? is it in the player options?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Collision Problem
« Reply #3 on: December 22, 2012, 04:47:03 pm »
The ortho camera size shouldn't matter. Well, if you want something with real world physics without changing ANY settings, then set it to something more sensible. It really depends on what your sprites are representing too. The ortho size = size from top to center of screen. So ortho = 1 means the distance is 2 units from top to bottom of the screen. By default the units are configured to meters in Unity, so thats 2m from top to bottom. You can scale appropriately depending on what you're trying to represent.

The target resolutions mentioned there is the pulldown on the game window selecting different resolutions. If you're running on PC/Mac/Webplayer then you won't have a 960x640 resolution by default - you can just configure that in the player settings.

TinSleeves

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: Collision Problem
« Reply #4 on: December 29, 2012, 12:32:29 am »
I have another collision problem, so I thought I'd add to this thread rather than start a new one. This time it has to do with tile maps and specifically where the chunks meet.

In my game the player can jump (who'd have thought it) however when the player is over the seam between chunks the jump power is a lot less and the player only jumps slightly off the ground. The image below should show what I mean:



My jump code is pretty basic so I don't think that's the issue

Code: [Select]
if(Input.GetButtonDown("Jump") && touchingPlatform)
{
jumping = true;
Jump();
}
void Jump()
    {
rigidbody.velocity = new Vector3(0, 0, 0);
        rigidbody.AddForce(new Vector3(0, jumpPower, 0), ForceMode.Force);       
    }

Any ideas whats causing this problem and if there is a work around?

Thanks!

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Collision Problem
« Reply #5 on: December 29, 2012, 06:13:26 pm »
No, I've not seen this before. Would be good if you could do a test case for me and email to support@unikronsoftware.com - at least I'll be able to look at it and try to work out what is causing it.

TinSleeves

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: Collision Problem
« Reply #6 on: December 29, 2012, 06:43:09 pm »
Just sent you over an e-mail
Thanks! ;D