Its easy enough to have an object instantly rotate to face specific coordinates. This is really useful for making enemies chase players using proximity. However, in the game I’m working on I want my enemy objects to have a slow rotation speed so they can gradually rotate towards where the players object is rather than instantly facing them.
I’ve put a little thought into it, and if I could get a simple true or false of whether or not the enemy is faster to rotate towards the players position by rotating left than rotating right I could make my game work fine. However I cant work out how to translate the players x and y coordinates in comparison with the enemies x and y coordinates to find whichever direction the enemy needs to rotate to face the player fastest. Any feedback or ideas to solve my problem would be great, cheers.
May I have a link to the game to see how your behaviors work please.
Sure, though I haven’t got anything much in place for this system yet. Currently its primarily random movements, but that’s only going to work so well…
I’m not really seeing a proximity on the enemy to make him move3 toward the you. Could you change it back to that maybe course it seems like you randomize it once you turn it back to the proximity like you said it was above i might be able to help you with the smooth roatation.
Yeah, I mean the thing is its a whole lot more complex than that because there’s a ton of other stuff going on in the background. For example the enemies can be both predators and prey depending which tier the player has reached. So lets just say we’re working with the Bot - fish object, and we’ll work on its predatory behaviors only. Currently the fish is really just moving randomly, then it rotates a little less consistently when it comes within a certain radius of a shrimp. What I wanna do is swap that change to less “spastic” rotation when it comes near a shrimp, to the gradual rotation towards a shrimp which I still have very little idea how to do yet.
Also keep in mind, I think that I might not actually want the fish to rotate towards the player because its hard enough as it is to avoid them, but higher tiered creatures like the penguins should definitely do it. So if I’m working on the fish its probably gonna end up a mechanic that makes it run away from penguins and seals rather than one making them run towards shrimp.
I hope that all makes sense to you, the fact of the matter is the game is already quite complex.
It makes a lot of sense actually but in all the years I’ve been working with Flowlab.io I have not seen anything be able to do what your trying to do it may be possible but it’s going to take behavior beyond behavior to maybe do that, so maybe @grazer can do a bit of updating to be able to make a behavior to do something similar to that I don’t know maybe it’s easier than we think but I just can’t seem to think of any thing to make it like that.
Perhaps a behavior that compares x,y coordinates and finds the direction out of 360, that is needed to face that point?
Something like that but you can change the speed of how fast it will turn toward the object.
Once you have the rotation the player is at, and the rotation they need to be at, getting them to that angle shouldn’t theoretically be too hard. For example if they are at 67 degrees (this could get a bit confusing because flowlab uses minus’s and plus’s depending on the direction they rotated to get there) and they need to be at say 185. You just need to minus one of them off the other and see whether its in the positives or negatives, and there you have your true or false output… true it is in the negatives, or false, it aint. Does that make sense?
So all you really need is something that allows you to find what direction you need to rotate to face (set coordinates). The set coordinates come from the proximity…
AHA, I think I’ve worked it out. The point at function does exactly what I need it to do except for one thing, it doesn’t just find the rotation value, it also sets the objects rotation to that value. All that needs to be done is the “point at” behavior needs to not automatically set the objects rotation. It should have to be plugged into the “rotation” behavior through the “set” port before doing that. It would just make the “point at” behavior more versatile and it would also theoretically solve my problem. Maybe its name should be changed to “find rotation” or something of that nature.
You can use the “Missile Example” from @JR01:
“This example shows how to slowly rotate a projectile to an object.
Look inside the Missile object for the “Homing Missile” behavior bundle.”
Wow posting other people example you pulling a me @PixelPizza very much so “smiling intensifies”
What’s wrong with that?
Examples are made to be shared and help people with specific problems.
I know I was just joking sorry if you thought I was being legit, ok I will stop joking around since nobody seems to think it’s a joke my mistake I will stop.
Thanks for that example @PixelPizza
I’m sure it will help me get what I want, cheers.
I gave the example a go but although I’m almost certain I have copied it exactly, it still wont work in my game.
There is a mouse icon at the left bottom corner, you can use it to copy/paste and import the code to your game.
Did you make sure that you updated the extractors?