GameSalad

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

orbiting around player megaman style

digitalzerodigitalzero Posts: 639Member, BASIC

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

  • SocksSocks London, UK.Posts: 12,822Member

    @digitalzero said:
    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 . . .

    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

  • digitalzerodigitalzero Posts: 639Member, BASIC

    where do you find radius? i don't see it in the expression editor

  • digitalzerodigitalzero Posts: 639Member, BASIC

    actually now that i really see this code i don't get it at all lol... what should i put in for angle

  • SocksSocks London, UK.Posts: 12,822Member

    @digitalzero said:
    where do you find radius? i don't see it in the expression editor

    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 ?

  • SocksSocks London, UK.Posts: 12,822Member
    edited September 2016

    @digitalzero said:
    actually now that i really see this code i don't get it at all lol... what should i put in for angle

    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

  • SocksSocks London, UK.Posts: 12,822Member

    Example

    Constrain x to 300 * cos (self.time * 100) + player's x
    Constrain y to 300 * sin (self.time * 100) + player's y

  • SocksSocks London, UK.Posts: 12,822Member

    Demo attached, click and drag the white player.

  • digitalzerodigitalzero Posts: 639Member, BASIC

    OMG @Socks you're the best!

  • digitalzerodigitalzero Posts: 639Member, BASIC

    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?

  • SocksSocks London, UK.Posts: 12,822Member

    @digitalzero said:
    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 ?)

  • digitalzerodigitalzero Posts: 639Member, BASIC

    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

  • SocksSocks London, UK.Posts: 12,822Member
    edited September 2016

    @digitalzero said:
    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...

    Yeah, that's made it a lot clearer, an actor shoots a gun that is almost like a shield that is a rotating bee
    :D :p

    @digitalzero said:
    so since I'm spawning it i can't edit it you see what i mean

    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.

  • digitalzerodigitalzero Posts: 639Member, BASIC

    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

Sign In or Register to comment.