Results 1 to 3 of 3
  1. #1
    Join Date
    May 2011
    Location
    Denmark
    Posts
    25

    Session 09 "255 - Improved Terrain R&D, Part 27" - Terrain Location bug

    Hello everyone,

    I've been following a long the session 09 with no trouble untill i hit the part 27. What happens is that after I've implemented the part were it checks the player's location and creates patches in front of the player as i move forward, i get a somewhat weird result.




    What happens is that it adds more patches in front of the patches that have been loaded in, and if i turn around it still loads patches at the place were it last created patches but in the direction i turned at so, say for example there are 50 patches in front of the direction i view at, those very last patches out there is for some reason what it thinks my location is, so if i turn 90 degree left, it starts to create more patches to the side all the way out there as if those patches was my location.

    TerrainDemo.cs - snippet
    public void Update()
    {
    TerrainManager.Update(TP_Controller.Instance.trans form.position);
    }

    public void FixedUpdate()
    {
    TerrainManager.FixedUpdate(TP_Controller.Instance. transform.position);
    PatchBuilder.Update();

    DrawDebugInfo();
    }
    TerrainManager.cs - Snippet
    private static Vector3 myPlayerPosition;

    public static Vector2 CurrentPatchLocation
    {
    get
    {
    return new Vector2(Mathf.RoundToInt(myPlayerPosition.x / PatchSize),
    Mathf.RoundToInt(myPlayerPosition.z / PatchSize));
    }
    }

    public static void Update(Vector3 playerPosition)
    {
    myPlayerPosition = playerPosition;


    }

    public static void FixedUpdate(Vector3 playerPosition)
    {
    myPlayerPosition = playerPosition;

    HandleTerrainPanning();
    }
    The panning works fine, its creating patches as supposed when i pan the camera view around, but the location stuff, well that's intresting.

    It basically thinks that the newest patches it has created are the current player position for some reason, but i cant see any difference in my code and the one shown in the video, that i am following along.
    Last edited by Blackbladez; 07-26-2012 at 11:05 AM.

  2. #2
    Join Date
    May 2011
    Location
    Denmark
    Posts
    25
    I still haven't found a solution to the problem. I hope that some of you may be able to point out keys of what it could be.

    Also by continueing, its very clear to see where it thinks my current location is. After implementing the remove patches feature(s).

    Last edited by Blackbladez; 07-28-2012 at 12:54 PM.

  3. #3
    Join Date
    May 2011
    Location
    Denmark
    Posts
    25
    Nevermind its fixed. I went back about 10 videoes and started to re-write some of the things, i re-wrote the entire TerrainManager and it worked. I also tried to compare the scripts but i still couldnt see what the difference was, but it just worked. So unfortunately if others encounter the same problem i cant say what the issue is.

Posting Permissions

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