Making actor go back and forth.
LogoLogic
Member Posts: 51
I am trying to get an actor to go back and forth across the screen so he does not disappear and reappear on the other side. I tried the pacing tutorial but the actor is still going off the screen and reappearing on the other side.
Thanks!
Thanks!
Comments
Pacing Actor, and two Bumpers.
Make one bumper for the left of the screen. And one bumper for the right side of the screen, and on these make sure "Movable" is unchecked in the physics tab of the actor. Inside Pacing Actor:
Rule: When Pacing Actor Collides with Bumper Right Side, (I use move alot of the time so that I know it will work) Move Left (180 degrees whatever) at Speed of 100 (change to your liking)
When Pacing Actor Collides with Bumper Left side, do the opposite, move Right(0 degrees) at speed of 100. and he'll repeat it himself. You can use the same bumpers for all of the obstacle characters in your game.
I am playing around with the timer and velocity right now. I can get him to move straight across the screen but he disappears and reappears.
Thanks TH.
constrain attribute : self X to sin( self.Time * "speed" ) * pixels to move + starting positionX
speed - any integer
pixels to move - any integer - for example if you put 30 the actor will go 30 to the right and 30 to the left , so the total movement will be 60 pixels wide.
starting positionX - the initial X value of the actor in the scene (do not use self.x)
play with the numbers till you rich your result.
hope it hepls
I will play around with both ways. Thank you.
Change Velocity to 200 (To set initial speed)
{
Every 3 Seconds (Change)
Change Attribute:
Self.Motion.LinearVelocity.X to -Self.Motion.LinearVelocity.X
}
math, your choice !
p.s , the way i mentioned dont required another actors,
just the constrain rule above in the moving actor.
good luck
I tried to follow you p-o-m and my head started hurting
Thanks.
In my actor I created a variabl called direction. I have a timer that says every X seconds (1 in my case ), change that attribute to (actor.Direction+1)%2. This switches the value from 0 to 1 and back every second
I the created two rules, go left and go right and just told them if direction is 1 move right. If direction is 0 move left you just need to adjust the timer to fit your screen nworked much better for me than the sin funcon
Sorry for typos, I'm on my iphone
Send and Receive Data using your own Server Tutorial! | Vote for A Long Way Home on Steam Greenlight! | Ten Years Left
I will keep playing around with it.
Just make a rule that says when self position less than or equal to some x value change direction. I have that rule in effect to keep my guy within a certain "boundary" and that seems to work really well.
Note you have to use the opposite value for the other end(right side of the screen: greater than or equal to).
IE.
RULE
Move left, speed 200 direction relative to actor
When self position <or= 5 move right, speed 200, direction relative to actor
When self position >or= 475 move left etc..
NOTE: >or< symbols(and not simply equals alone) will ensure that if GS stutters and misses your actor at the specified pixel value it will still trip the rule.
I did this
http://img268.imageshack.us/img268/295/screenshot20100708at815.png
and the actor just moves continuously to the right and comes across the screen and keeps going that way. Can you help?
Thank you.
http://img708.imageshack.us/img708/295/screenshot20100708at815.png