Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 2005
    Posts
    8

    Unhappy 2D Game in Unity - Raycasting issue - more like RayCharles than Raycast

    I did the Horizontal movement looked over my own code several times side by side with the video everything is exact, it will move but the raycast is way down and to the left behind the player when he is moving right, if i move left the raycast is still down and to the left, i even did the vertical movement and it is doing a similar thing, if i place the player above a standing tile..he rises up in the air by about a whole tile in size. I dunno what's going on at all.

    I also redid all my tiles again but it still does the same thing

    Any help or any ideas would be much appreciated...Frakking thing is doin' my head in !

    regards scuzzy

  2. #2
    Join Date
    Aug 2011
    Location
    Kansas
    Posts
    181
    I have the same problem. My raycasts on the left are off (top, bottom and right seem fine) and I've gone through the code at least twice.

    I played with the boxcollider2D size but that didn't help. I started tinkering with the code that computes the raycasts, but I couldn't get any change. The effect of this for me is that I get stuck on walls if I impact them with the left side of the player. It's a very frustrating problem and I haven't figured out what is wrong yet

  3. #3
    Join Date
    Aug 2011
    Location
    Kansas
    Posts
    181
    OK, went through and re-did the player prefab from the ground up and ended up scaling him a bit smaller. Re-watched the prefabs video and tried to match Nelson's scaling as much as I could (I was a little off for some reason). That seemed to help. The problem is gone in about 90% of the instances where I hit it before... so I'm getting there.

  4. #4
    Join Date
    Jul 2005
    Posts
    8
    That's great man glad to hear it, hopefully you'll get it 100%

    I moved on to the next video the slopes one, works fine going downhill but still really slow and stuttery on the uphill even using the max 90% climb angle, i can live with it for now, but the next video with the Camera Controller just isn't happening for me at all, it doesn't follow the player or move up if he jumps up above the screen...something did happen with the game view a few days back and it was never the same after that so it was probably something stupid i did, just can't seem to figure it out though, so i guess it's more hours playing around with it.

  5. #5
    Join Date
    Jan 2015
    Posts
    2
    I have seen several issues where raycasts seem to be at the wrong origin. Usually it's when I have accidentally moved the character body, or platform sprite which leaves the 2D Collider for the prefab not aligned with the sprite. Since the collisions and rays are done on the collider, they are correct but the visual is that they are wrong when compared to the sprite.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •