Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Camera is not moving

Discussion in 'Project Tiny' started by GlebZ123, Dec 27, 2018.

  1. GlebZ123

    GlebZ123

    Joined:
    Dec 3, 2015
    Posts:
    3
    Hi! I have implemented CameraFollowSystem. It takes player's position and applies it to camera's transform.
    Console logs in browser that position of camera changes, but visually it doesn't.
    Is it possible to move camera in tiny mode?
    Thanks!
     
  2. abeisgreat

    abeisgreat

    Joined:
    Nov 21, 2016
    Posts:
    44
    Can you share your code? Are you modifying the camera's position in world.usingComponentData() or equivalent? If not, that could cause it to appear to be updating the value but not have any effect on the game.
     
  3. vincismurf

    vincismurf

    Joined:
    Feb 28, 2013
    Posts:
    200
    Did you set the modified component data back to the entity?
     
  4. GlebZ123

    GlebZ123

    Joined:
    Dec 3, 2015
    Posts:
    3
    I have tried two approaches. Both of them don't move the camera.

    First:
    Code (CSharp):
    1. this.world.forEach([ZPlayerTag, ut.Core2D.TransformLocalPosition],
    2. (playerTag, playerTransform)=>
    3. {
    4.     this.world.forEach([ut.Entity, ZGameplayCameraTag, ut.Core2D.TransformLocalPosition],
    5.     (cameraEntity, cameraTag, cameraTransform)=>
    6.     {
    7.         cameraTransform.position = playerTransform.position;
    8.         this.world.setComponentData(cameraEntity, cameraTransform);
    9.         console.log("camera: ",cameraTransform.position);
    10.     });
    11. });
    Second:
    Code (CSharp):
    1. this.world.forEach([ZPlayerTag, ut.Core2D.TransformLocalPosition],
    2. (playerTag, playerTransform)=>
    3. {
    4.     let cameraEntity = this.world.getEntityByName("GameplayCamera");
    5.     this.world.usingComponentData(cameraEntity, [ut.Core2D.TransformLocalPosition],
    6.     (cameraTransform)=>
    7.     {
    8.         cameraTransform.position = playerTransform.position;
    9.         this.world.setComponentData(cameraEntity, cameraTransform);
    10.         console.log("camera: ",cameraTransform.position);
    11.     });
    12. });
     
  5. GlebZ123

    GlebZ123

    Joined:
    Dec 3, 2015
    Posts:
    3
    I've figured out. Now both approaches work.
    The issue was in initial camera in Bootstrap group.
    It wasn't rendering anything, but for some reason blocked changes to GameplayCamera.
    I have deleted initial camera from Bootstrap and now it works.
    Thanks!