Spawn Object Facing Object's Center
KillerPenguinStudios
Member Posts: 1,291
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
BUMP!
I'm not quite sure what the question is, some of the language is a little mysterious
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.
Hey @Socks,
Sry to be so mysterious! 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 ?
Please hold as I torture myself so I can do so! hahaha
Yes, that is basically my question! Thanks!
Simply Rotate To the target's X and Y.
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.
What ?
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.
@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".
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!
You are welcome!