GameSalad

Howdy, Stranger!

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

Rotate and follow

saad1993saad1993 Posts: 47Member, BASIC

Hello. So I've been able to make actor B rotate around actor A using the cos and sin formula, thanks to the brilliant forum help. What I can't figure out, or find in the forums, is how to make actor B rotate around and follow actor A.

So if actor A moves up and down, actor B should move with it while still rotating around actor A. Currently, actor B just spawns near actor A and rotates around it, but when I move it, actor B remains in the fixed position and keeps rotating.

Appreciate the help!

Comments

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

    @saad1993 said:
    Hello. So I've been able to make actor B rotate around actor A using the cos and sin formula, thanks to the brilliant forum help. What I can't figure out, or find in the forums, is how to make actor B rotate around and follow actor A.

    Simply add actor A's position to actor B's position.

    Does that make sense ?

  • saad1993saad1993 Posts: 47Member, BASIC

    @Socks said:
    Simply add actor A's position to actor B's position.

    Does that make sense ?

    Makes perfect sense. I did that by adding the X and Y positions of actor A into constrain attribute rules of actor B, along with the cos and sin formula. But it doesn't work.

    Could it be because actor A's X position is constrained to a certain value and can only move up and down? Could it be because actor A can be moved with a touch and slide input?

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

    @saad1993 said:
    Could it be because actor A's X position is constrained to a certain value and can only move up and down? Could it be because actor A can be moved with a touch and slide input?

    No, that would have no effect on the maths, can you share a screenshot of your code for actor A and B ?

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

    Example attached:

    AB.zip 17.2K
  • SocksSocks London, UK.Posts: 12,822Member

    Same thing, but you drag actor A with the mouse:

    ABC.zip 18.2K
  • saad1993saad1993 Posts: 47Member, BASIC
    edited September 2016

    @Socks said:
    Same thing, but you drag actor A with the mouse:

    You're using the formula you showed on the instance of the rotating character. I want to be able to make all prototypes of the rotating character behave in that way. This is because the character will be destroyed and re-attained by the movable character (Character A). For Character A, all I have is a constrain attribute to broadcast the positions of it's X and Y as a game attribute.

    Kind of lost with this.

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

    @saad1993 said:
    You're using the formula you showed on the instance of the rotating character.

    I'm not sure what this means, I've not shown any formula ?

    @saad1993 said:
    I want to be able to make all prototypes of the rotating character behave in that way.

    How many prototypes of the rotating character do you have ?

    @saad1993 said:
    For Character A, all I have is a constrain attribute to broadcast the positions of it's X and Y as a game attribute.

    Kind of lost with this.

    I'm not sure what the question is ? What is it - specifically - that is preventing you from doing what you need to do ?

  • saad1993saad1993 Posts: 47Member, BASIC

    @Socks said:

    I'm not sure what this means, I've not shown any formula ?

    In the gamesalad file you sent, you're using the constrain attribute behavior on the instance of actor B, not on prototypes.

    How many prototypes of the rotating character do you have ?

    Technically, unlimited, since it is an endless game.

    I'm not sure what the question is ? What is it - specifically - that is preventing you from doing what you need to do ?

    The problem is that actor B rotates in a fixed spot after spawning in the position where actor B is. It does not move with actor A, it just keeps rotating at that spot. I require it to move with actor A, while rotating around actor A.

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

    @saad1993 said:
    The problem is that actor B rotates in a fixed spot after spawning in the position where actor B is. It does not move with actor A, it just keeps rotating at that spot. I require it to move with actor A, while rotating around actor A.

    Like I say above, simply add actor A's position to actor B's position, it really is as simple as that ! I'm actually still not sure what the issue is ? By that I don't mean that I don't know what the question is, I mean that the answer has been given and I'm not sure what the issue is with implementing it ?

  • jay2dxjay2dx Posts: 606Member

    Make sure you don't have "do not move" ticked within the actors attributes! Worth a shot!

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

    @jay2dx said:
    Make sure you don't have "do not move" ticked within the actors attributes!

    If by don't have "do not move" ticked you mean do have "movable" ticked then that won't effect anything as Constrain behaviours are outside of the physics engine, so "movable" has no effect on how they work.

  • jay2dxjay2dx Posts: 606Member

    Ah cool, hope this guy gets it sorted, yeah I couldn't remember what it was actually called, just browsing the forums while in my work commute train :)

Sign In or Register to comment.