Left and right
rubber-chicken
Member Posts: 12
Hi
I have an actor which is the player, he is facing right and shoots to the right. How do I get him to face left when the left key is pressed and shoot to the left also??
I have an actor which is the player, he is facing right and shoots to the right. How do I get him to face left when the left key is pressed and shoot to the left also??
Comments
Use that with a Change Image behavior when you press the left key.
Create an actor attribute that you set to know when you are facing left or right. Then use that attribute when you look for the key to shoot and have different spawn behaviors depending on which way you face(the attribute)
I managed to get the same thing done with two actors - one for left, one for right - that destroyed eachother and spawned the other actor when the key was pressed.
So if the Right facing actor has the left key pressed, it destroys itself and spawns a left facing actor etc etc.
This does, of course, mean you have to double up your rules for each actor, with minor tweaks (like shooting in a certain direction etc)
Dr. Sam Beckett never returned home...
Twitter: https://twitter.com/Quantum_Sheep
Web: https://quantumsheep.itch.io
left arrow down constrains attribute to 1
right arrow constrains to 0
1 moves 180 from actor
0 moves 0 from actor works but if you switch left and right the spawned actor switches midflight, how do i alleviate this. Also my main actor has drift and accelerate for move so he continuous to drift in a direction after releasing direction arrow how do i get him to continue to shoot in that direction if the key is released? Is there a way to make an attribute know what image the actor is?
i might have to try that spawning technique, should work with drag, no?
when right key is down
CHANGE attribute facingright = true(1)
move (or accelerate) 0degrees
change image to guy facing right
when left key is down
change attribute facingright = false (0)
move 180degrees
change image to guy facing left
now for the shooting
when shoot button is down
AND facingright is true
spawn bullet actor (angle = 0)
when shoot button is down
AND facingright is false
spawn bullet actor (angle = 180)
in the bullet use a move or velocity or accelerate behavior (experiment until it works to your liking) Don't set the angle of motion in the bullet (leave at 0 relative to actor) The angle gets set in the shooter actor that is spawning the bullet.