Spawn Object Facing Object's Center

Hello GS,

I am having a brain fart at the moment. I am pressing an object and having it spawn an object every time it is pressed. What I trying to accomplish is every time I press the actor anywhere I want the spawned in actor to be facing its center.

I believe I should be using vector to angle but can't think straight at the moment.

Thanks in advance!

Comments

  • KillerPenguinStudiosKillerPenguinStudios Member Posts: 1,291

    BUMP!

  • SocksSocks London, UK.Member Posts: 12,822
    edited April 2015

    I'm not quite sure what the question is, some of the language is a little mysterious :smile:

    Are you simply trying to get a spawned ('spawned in' ?) actor to rotate towards a target ?

    If that is what you want then you could use Rotate To with the X and Y set to the target's X and Y.

  • KillerPenguinStudiosKillerPenguinStudios Member Posts: 1,291

    Hey @Socks,

    Sry to be so mysterious! :p lol

    Here's what I have and am trying to accomplish. In my scene I have an button actor that says;

    When touch is pressed;
    Spawn actor "A"

    In the spawn rule I have it spawning to the mouse.position.x & y

    In the direction part I want the spawned in actors direction to always be facing the button actors center.

    Hopefully that makes more sense and isn't as mysterious anymore! Lol

  • SocksSocks London, UK.Member Posts: 12,822
    edited April 2015

    @KillerPenguinStudios said:
    Hey Socks,

    Sry to be so mysterious! :p lol

    Here's what I have and am trying to accomplish. In my scene I have an button actor that says;

    When touch is pressed;
    Spawn actor "A"

    In the spawn rule I have it spawning to the mouse.position.x & y

    In the direction part I want the spawned in actors direction to always be facing the button actors center.

    Hopefully that makes more sense and isn't as mysterious anymore! Lol

    If you were under duress, tortured perhaps, would you be able to express what you want in a single sentence ? Like "I want a spawned actor to face its spawner" ? Is that basically the question ?

  • KillerPenguinStudiosKillerPenguinStudios Member Posts: 1,291

    @Socks said:
    If you were under duress, tortured perhaps, would you be able to express what you want in a single sentence ? Like "I want a spawned actor to face its spawner" ? Is that basically the question ?

    Please hold as I torture myself so I can do so! :p hahaha

    Yes, that is basically my question! Thanks!

  • SocksSocks London, UK.Member Posts: 12,822
    edited April 2015

    @KillerPenguinStudios said:
    Yes, that is basically my question! Thanks!

    :smile:

    Simply Rotate To the target's X and Y.

  • KillerPenguinStudiosKillerPenguinStudios Member Posts: 1,291

    @Socks said:
    :smile:

    Simply Rotate To the target's X and Y.

    That's one of the first things I tried but didn't work. Maybe I'm doing it incorrectly. Here's a screen shot.

  • SocksSocks London, UK.Member Posts: 12,822
    edited April 2015

    @KillerPenguinStudios said:
    Here's a screen shot.

    What ? :smile:

    That's not the Rotate To behaviour, that's the Spawn behaviour !?

    Just place a Rotate To behaviour in the spawned actor and set it so that it points towards the spawner actor.

  • KillerPenguinStudiosKillerPenguinStudios Member Posts: 1,291

    @Socks said:
    What ? :smile:
    That's not the Rotate To behaviour, that's the Spawn behaviour !?
    Just place a Rotate To behaviour in the spawned actor and set it so that it points towards the spawner actor.

    The reason I was trying to place it in the spawn rule was because I wanted it to call the direction of the spawner actor.

    I used rotate to position but now the issue I am having is that it requires a speed at which it will rotate it to that position and I need it to be instantly. I'm attaching my project where I am wanting the arrow to point to the center of the target. If you have time if you could look at it.

    Thanks again for taking the time and helping me.

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880

    @KillerPenguinStudios -- use vectorToAngle in the spawn actor's direction field:

    vectorToAngle( self.Position.X - game.Mouse.Position.X , self.Position.Y - game.Mouse.Position.Y )

    Be sure to make it "relative to scene".

  • KillerPenguinStudiosKillerPenguinStudios Member Posts: 1,291
    edited April 2015

    Thank you @RThurman,

    It works now! Your a life saver and I truly appreciate you helping me!

    Also, thank you @Socks for the provided help you gave me! I greatly appreciate it!

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880

    You are welcome!

Sign In or Register to comment.