RPG selecting system
SkyMaple
Member Posts: 817
I started making an rpg but I'm faced with a problem. In most games your player has to be facing an object to select it for various actions. How can I do this without being able to select an object when the player is facing away from it?
Comments
Make an attribute "Interact"
If attribute "facing left" = "true" and attribute "facing right" = "false" set attribute "interact" to 0
If attribute "facing right" = "true" and attribute "facing left" = "false" set attribute "interact" to 1
On the object to be interacted with...
(If colliding or if magnitude is met...or whatever you have for interaction with the object) and attribute "interact" = 1 destroy this actor/spawn actor/ set attribute "bullet count" to "bullet count"+100...etc...
If attribute "interact" = 0 then do nothing
If overlaps or collides with "line of sight"
and overlaps or collides with "Hero"
Then... run behaviors
The position of the "Line of Sight" actor would be constrained using cos and sin.
@photics if you could give me some code for your idea that would be awesome!
Basically... it involves aligning your actor (and image) to the 0° angle, and using a circle
(cos( game.HERO-Rotation)*12)+ game.HERO.X
(sin( game.HERO-Rotation)*12)+ game.HERO.Y
...but that's like five constraints...
three for the hero and two for the line of sight.
...maybe three if you constrain the line of sight actor's rotation to the same angle as the hero's angle.
I'm thinking you might have have mixed something.
Heh, looks like the start of a fun game though.
Heres the code. And thanks! This is the beginning of an RPG.
EDIT: Its small on here, just open the image in a new tab.
Is there something I need to add to the rotation?
I dont know. Its supposed to rotate around the hero when he moves. right now it just stays in the same place.
If overlaps/collides with line of site
AND overlaps/collides with hero
Then... run behaviors