Determine the direction in which you are looking with code
I am looking for a way in the MC:EE code editor to determine the direction in which the player is currently looking and to process this direction as a value. For example: "North" or "South-East" as the value of a variable. Does anyone have an idea for querying this via the Make Code Editor or Python?
The use-case is as follows: We are currently programming a "magic" sword that, when I use it (strike it), draws lightning bolts across the landscape in a chain. The problem is, how does the code editor know in which direction I am looking or striking with the sword?
-
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.
0 -
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 10000I haven't got it nailed down, but there is hope. =]0 -
when I try it in python it has 2 error and says it does not work is there any other way.
0 -
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")0 -
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.
0
Please sign in to leave a comment.
Comments
5 comments