How do I…
I created a cone of vision for the enemy AI, which uses a collision to check if the player is colliding with it to perform the AI’s response. I have added a rectangle movement behavior to the AI, so that it’s patrolling an area. During certain angles, the origin that I had created for the enemy AI is not updating correctly and is causing the cone to move inside of the sprite instead of keeping in front of the enemy AI where the origin is positioned.
What is the expected result
The cone should rotate correctly with the origin point.
What is the actual result
The cone is not keeping true to the origin point.
Use the sticker extension for this instead. It’s a one-line action, you won’t need to move the cone and it will solve your problem.
Here’s a link on how to use it.
Thank you for your reply MrMen,
I have given this an attempt, but it appears as though I’m either using it wrong or it doesn’t work good for objects that are created through script. I spawn the enemy AI at specific coordinates, spawn the cone and set its position to the specific point. Then I am sticking the cone to the enemy AI. But, it appears to not update at all. Does the sticker only work if you preplace objects into the scene?
Keeping the original reply to expose my mistake.
I realize that I accidentally assigned the sticker to the player character and not the enemy AI. Thank you for your suggestion MrMen, I greatly appreciate your help.
Although, I’m still curious as to why the cone sprite was not updating its position correctly with the “Front” point.
For 2 reasons:
1.The cone’s origin and centre of rotation have to be at the same position
2. The cone needs to be repositioned after the SpacxeSquidEnemy has been rotated, not before.
However, this may still not work if the rotate is performed (by GDevelop) at the end of the frame - I’m not familiar with the inner workings of that. So instead of rotating instantly, set the angle of both objects.