Skip to main content

Determine the direction in which you are looking with code



  • Aleece Landis
    Bug Zapper Beacon of Knowledge Super Star

    Hum, it seems to me that this should be possible somehow (seeing as you can adjust which way the agent faces for things,) I'm just not quite sure how to go about it.

  • Debbie Alexander
    Moderator Beacon of Knowledge Super Star

    With the update, I had hope for the new Python Notebooks function, player.look_at(location) - but it only returns a value, true or false, and doesn't do anything like what I would think goes with the idea of "looking at" something =D. That said, there are a dozen shiny new player commands ready for tinkering, so that's good news on other fronts!

    ********************** edit ******************************

    Some days I just LOVE being wrong! 

    Here is how it works:

    player.look_at("0 0 20000")
    You have to manipulate the last number. It won't let you look up and down as far as I can tell (at school now so no more time to tinker!) But all else remaining the same, you can get yourself to turn around with numbers like 0 0 0 and 0 0 100 and 0 0 10000
    I haven't got it nailed down, but there is hope. =]
  • Kane Mason

    when I try it in python it has 2 error and says it does not work is there any other way.

  • Moderator Beacon of Knowledge Super Star

    Kane Mason  Are you using Python Azure Notebooks? 

    That's not the MakeCode version of Python, it's the one with the Blue Notebook. These worked for me.

    player.look_at("0 0 -5000")
    player.look_at("0 0 20000")
  • Christoph Peters

    It is possible now to determine the direction player is looking! They added the function posLocal(), which returns a position in the direction where the player is looking. 

    In Makecode you can find it in the Position and Player tab.



Please sign in to leave a comment.