Hello Guest

Author Topic: CharacterController Player Sliding  (Read 13714 times)

JBabz

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 42
  • @joe_babz
    • View Profile
    • Zombit on Facebook
CharacterController Player Sliding
« on: July 19, 2013, 03:21:40 pm »
Okay, so I have the player on a CharacterController, because I want simple top-down movement.
The issue is that the player acts sort of like a hockey puck when I use the keyboard, but the player works just how I want him to when I use the joystick.
Is there anyway to make the player behave like he does when I use the joystick all the time?
Here is a video, the first square he makes is with the joystick, and the second square he makes is with the keyboard.
Also attached is a picture of the player's behavior script.

What do I need to change?

Thanks!

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: CharacterController Player Sliding
« Reply #1 on: July 19, 2013, 06:59:13 pm »
I can't really make out anything in that video. Try posting to youtube or something, the encoding looks like its messed everything up.
Anyway- one thing I noticed was that you're moving the character controller on XY.

One thing to note though - If you need to do top down movement, you should rotate the tilemap so it lies on the XZ plane, and rotate all your sprites so they do the same thing. The character controller won't slide along the Y axis, but behaves perfectly on the XZ plane.

robmpreston

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: CharacterController Player Sliding
« Reply #2 on: August 04, 2013, 01:51:21 pm »
I can't really make out anything in that video. Try posting to youtube or something, the encoding looks like its messed everything up.
Anyway- one thing I noticed was that you're moving the character controller on XY.

One thing to note though - If you need to do top down movement, you should rotate the tilemap so it lies on the XZ plane, and rotate all your sprites so they do the same thing. The character controller won't slide along the Y axis, but behaves perfectly on the XZ plane.
Hello,

Could you give me some guidance on how to do this? A simple example would be great, thanks.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: CharacterController Player Sliding
« Reply #3 on: August 04, 2013, 04:02:30 pm »
All you do is take the tilemap and set rotation to X:90 Y:0 Z:0
Set the player to the same thing, and you're done.

robmpreston

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: CharacterController Player Sliding
« Reply #4 on: August 04, 2013, 05:44:30 pm »
All you do is take the tilemap and set rotation to X:90 Y:0 Z:0
Set the player to the same thing, and you're done.

Ok did that, but what would be the proper settings for the camera in this case for it to show anything?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: CharacterController Player Sliding
« Reply #5 on: August 04, 2013, 06:02:17 pm »
No but surely it's obvious what to do to the camera? Just move it and rotate it in the same way so its looking down at the tilemap...
You'll need to change the movement code so its moving in the XZ plane as well.
« Last Edit: August 04, 2013, 06:05:04 pm by unikronsoftware »

robmpreston

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: CharacterController Player Sliding
« Reply #6 on: August 05, 2013, 01:11:19 am »
Most of my previous game development has been in a 2D environment so I'm not too familiar with the 3d setup. I rotated my map and sprites as suggested, and tried to set my camera similarly but get nothing displayed. If I mess with it, I can get the map to show somewhat but not correctly so I guess I just don't get it right now. Sorry if I'm coming off stupid here, but I guess I'll give up on this idea for now.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: CharacterController Player Sliding
« Reply #7 on: August 05, 2013, 09:17:27 am »
Your camera is probably at the same y position as the sprite? Here are my settings that work - I can't provide a download of this as it uses some random artwork off the internet as a test.

Tilemap, pos = 0,0,0 rot = 90,0,0 scale = 1,1,1
Player sprite, pos = 0,0,0 rot = 90,0,0 scale = 1,1,1
Camera, pos = 0,10,0 rot = 90,0,0 scale = 1,1,1 - far clip plane = 100

The camera has to be "higher" than the tilemap to be able to see it. You can work this out by rotating scene view around a bit so you can see the box around the camera and where your sprite is in relation - it needs to be inside the box to be visible.

robmpreston

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: CharacterController Player Sliding
« Reply #8 on: August 05, 2013, 04:33:06 pm »
Ok, got that all set up perfectly and changed all my movement code from y to z. The only weird thing now is when I use the Move() for my character controller, he moves slowly no matter what (like 1 pixel each time) even if my speed is set high.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: CharacterController Player Sliding
« Reply #9 on: August 05, 2013, 04:57:48 pm »
Are you moving in XZ now instead of XY?

robmpreston

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: CharacterController Player Sliding
« Reply #10 on: August 05, 2013, 05:27:45 pm »
Yes, as I said I changed all of my camera and movement code from y to z, so I am moving x and z instead of x and y. Otherwise the code is identical.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: CharacterController Player Sliding
« Reply #11 on: August 05, 2013, 10:10:09 pm »
Cant' think of what could be wrong, but if you want, zip up your project and mail to support at unikronsoftware dot com. I'll be happy to look at it for you and work out whats wrong.

robmpreston

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: CharacterController Player Sliding
« Reply #12 on: August 06, 2013, 04:47:19 pm »
Thanks. I'll try to create a small demo tonight to send over to you.

robmpreston

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: CharacterController Player Sliding
« Reply #13 on: August 07, 2013, 11:55:21 am »
Played with it some more - pretty sure the problem was something with the settings on the Character Controller itself. Seems to be working well now.

robmpreston

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: CharacterController Player Sliding
« Reply #14 on: August 08, 2013, 02:46:42 pm »
I am still noticing it a bit, for the most part moving in the +-z and +x position works fine, but -x sometimes lags, slows down or stops. Any idea why this is? Could it be some settings in my character controller?