I want to make a mob that does certain actions when you look at it, and different actions when it is out of view. Is there any way that I can check if the mob is in the player's view?
I want to make a mob that does certain actions when you look at it, and different actions when it is out of view. Is there any way that I can check if the mob is in the player's view?
hmm this is a good question. yes it is possible to isolate movements when the player views objects and to create other actions when the player looks away this happens in other games and would be relatively small in terms of code (between 50 and 500 lines is what i call "small") the only question would really be how would you define the actions? would it be something along the lines of key activations (events cause events) or common to static variable movements? (EX: playersight = null/0 = "exe = "action") yes that is just a bit of a sloppy example but it works in explaining it to people who cant write programs very well. the two things you would have to do is.
1) set a variable for player sight
2) create an event to use the variable
now this is extremely simple in what to do but in execution it would take some trial and error to write a completely function system where this works properly and the code would probably overlap with player movement (since it follows the same rules) so id say start there. then look into chunk loading and creation, finally into lighting and functionality this is more of time based effort that it is of work. plus im just a novice at programming (year of visual under my belt and i just started learning java) so you dont have to take my advice. but its just a keen idea on how it all works. good luck if your going to try and remember you need alot of patience to create something in java.
I knew that already, I just wanted to know if there was a method that would allow me to check such a thing. Like a method in an entity that tells me whether it is being rendered (I assume unrendered mobs are out of the FOV), or even something like the direction that the player is facing, as well as the field of view angle, so I can use trigonometry if need be to figure this out.
I knew that already, I just wanted to know if there was a method that would allow me to check such a thing. Like a method in an entity that tells me whether it is being rendered (I assume unrendered mobs are out of the FOV), or even something like the direction that the player is facing, as well as the field of view angle, so I can use trigonometry if need be to figure this out.
ok i get what you're saying i'd assume that you could use the lighting system (any object not in view is given a lighting value of null so that it doesn't eat your computers ram and cpu but not 0 as that is actually a set value since lighting values range from -25 to 25 (max darkness to max light)) the only problem with this is how would you move an object thats currently unrendered? unless you wrote an exception to the rendering file so the mob could move when its not rendered but this would require a lot of rewriting the more complex code in minecraft or a complex additional class file.
P.S. i just got out of class after class and i' am NOT feeling very well so if it sounds like i'm going in circles its due to me being tired.
you wouldnt happen to be doing this for something like a weeping angels mob, would you?
and also, if, for example, you wanted to move something towards the player when it wasnt in view, then couldnt you just update its position from where it was to where you want it to be by using a function?
you wouldnt happen to be doing this for something like a weeping angels mob, would you?
and also, if, for example, you wanted to move something towards the player when it wasnt in view, then couldnt you just update its position from where it was to where you want it to be by using a function?
Yes, actually, that is the kind of mob I'm trying to make.
I could do that, but my main concern right now is to make events happen only when not in vision of the player. I can figure out the rest later, such as movement.
hmm this is a good question. yes it is possible to isolate movements when the player views objects and to create other actions when the player looks away this happens in other games and would be relatively small in terms of code (between 50 and 500 lines is what i call "small") the only question would really be how would you define the actions? would it be something along the lines of key activations (events cause events) or common to static variable movements? (EX: playersight = null/0 = "exe = "action") yes that is just a bit of a sloppy example but it works in explaining it to people who cant write programs very well. the two things you would have to do is.
1) set a variable for player sight
2) create an event to use the variable
now this is extremely simple in what to do but in execution it would take some trial and error to write a completely function system where this works properly and the code would probably overlap with player movement (since it follows the same rules) so id say start there. then look into chunk loading and creation, finally into lighting and functionality this is more of time based effort that it is of work. plus im just a novice at programming (year of visual under my belt and i just started learning java) so you dont have to take my advice. but its just a keen idea on how it all works. good luck if your going to try and remember you need alot of patience to create something in java.
ok i get what you're saying i'd assume that you could use the lighting system (any object not in view is given a lighting value of null so that it doesn't eat your computers ram and cpu but not 0 as that is actually a set value since lighting values range from -25 to 25 (max darkness to max light)) the only problem with this is how would you move an object thats currently unrendered? unless you wrote an exception to the rendering file so the mob could move when its not rendered but this would require a lot of rewriting the more complex code in minecraft or a complex additional class file.
P.S. i just got out of class after class and i' am NOT feeling very well so if it sounds like i'm going in circles its due to me being tired.
and also, if, for example, you wanted to move something towards the player when it wasnt in view, then couldnt you just update its position from where it was to where you want it to be by using a function?
Yes, actually, that is the kind of mob I'm trying to make.
I could do that, but my main concern right now is to make events happen only when not in vision of the player. I can figure out the rest later, such as movement.