orbiting around player megaman style
digitalzero
Member, BASIC Posts: 639
hey you all! so what I'm trying to do is make an actor orbit around the player... now the player can move left and right but i want its special to have an actor orbit around it... a bee specifically... i know it has something to do with the player x and player y game attributes but from there i have no idea... i also do not want the actor to rotate... it would be pretty weird to see an upside down bee chillin lol i have checked some of the questions on the forum and either they are outdated or it does not work... please someone help me out! thanks so much
Comments
Constrain the orbiting actor's x to Radius * cos ( angle ) + player's x
Constrain the orbiting actor's y to Radius * sin ( angle ) + player's y
where do you find radius? i don't see it in the expression editor
actually now that i really see this code i don't get it at all lol... what should i put in for angle
You've not presented any values in your question (i.e. "I want an actor to orbit at a distance of 180 pixels, going at a speed of 40 degrees a second in a counterclockwise direction) - so I've had to keep my answer generic, I could of course have made up some values, but that can often confuse people ("hey I tried your code and the actor is orbiting way too fast !" . . etc) . . .
So . . .
Radius = the radius of your orbiting actor.
Angle = the angle of your orbiting actor.
Hopefully that makes more sense ?
What would you like the angle to be ? People usually want the angle to be a value that is always rising (so the orbiting actor's angle constantly increases - and therefore constantly orbits the player) . . . a quick cheat for an ever rising value is to use self.time or game.time . . . . but self/game.time is measured in seconds, so after - for example - 10 seconds it will give you a value of 10, so the orbiting actor would have moved only 10 degrees . . . or to put it another way it would take 6 minutes to rotate a full 360 degrees, so usually people speed up this value by multiplying the value of self/game.time . . . so self.time * 100 for example will increase a hundred times faster than self.time . .
Of course you don't have to use self/game.time for the angle, you could use anything you want, an interpolated value, a constrained value . . . etc etc
Example
Constrain x to 300 * cos (self.time * 100) + player's x
Constrain y to 300 * sin (self.time * 100) + player's y
Demo attached, click and drag the white player.
OMG @Socks you're the best!
oh snaps @Socks i noticed that you edited the code in the actual prototype and not the actor... but for this it would need to be spawned so i would need it to be in the actual prototype... you know what i mean?
I sort of do, I think ? But I'm not sure what the issue is ? Is the question 'how do you get two actors to exchange information' (if I understand the question correctly ?)
okay @Socks lets say this... i want an actor that shoots a gun but when he shoots the gun it is almost like a shield effect but the shield is a bee that rotates around the player... so since I'm spawning it i can't edit it you see what i mean
Yeah, that's made it a lot clearer, an actor shoots a gun that is almost like a shield that is a rotating bee
Sort of, I think you are asking how can you get two actors to exchange information ?
If that's what you mean, then you'd simply use attributes, one actor constrains a couple of attributes to its x and y values and then the second actor can access those values. Make sense ?
. . . . . . .
Example, we have two actors, A and B, and we want B to follow A's movement.
A is moving around the screen, for this actor we say constrain attribute XXX to this actor's x position and constrain attribute YYY to this actor's y position.
Then for Actor B, we say constrain this actor's x position to attribute XXX and constrain this actor's y position to attribute YYY.
Now actor B will follow the movement of actor A.
hahahahahhaha oh @Socks you're the best... thats exactly what i was trying to get at! thanks so much for your patience and understanding... lol you been dealing with me for years now lol