How do I create Actors with a rotation.

Krail

  • Posts: 32
I'm making run and gun sort of game where the main character can shoot shaped energy blasts in various directions.  At the moment I'm creating recycled bullets, then using the "point LastCreatedActor towards ___ degrees" block for when the bullets are fired in different directions.  With this you can frequently see a bullet in it's original rotation for a single frame before the rotate line is called.

How can I get around this?  How can I set rotation on creation, instead of one line after?  It seems like there should be a second create function with parameters for x, y, and rotation, but I'm not seeing one.

Abigayl

  • Posts: 807
It's pretty simple: Don't use recycled actors. I have heard that they improved in 2.0, but to get around the issues takes a deeper programming knowledge.

If you really want to use recycled actors, make a custom block in the actor's coding and in it do all of the initialization; then, call that block whenever you make the actor. That method should work.
If you need help, please check my tutorials either here or Kongregate (http://www.kongregate.com/accounts/Abigayl) or come over to my stream: http://www.livestream.com/poweredbyflowers

zeljko46

  • Posts: 84
Well animate it like it is rotating, it is the best way  ;)
Play my game: http://www.kongregate.com/games/zeljko46/idle-downloader
Feedback, suggest, and if you want, offer help :)

Krail

  • Posts: 32
What does recycling actors have to do with it?  I mean, I wasn't using recycle originally, and I still saw the same problem when the bullets were created.

I'm still a little confused about what recycling means and when to use recycling and when to just use create/kill.  If I understand correctly, a recycled actor is removed from the scene but maintains its position in memory and the game holds a reference to it, and it's called on when that same actor type is used again, whereas for a created actor... the actor is deleted on kill and a new one is instantiated on create?

As for your suggestion, are you saying I should have the actor's constructor receive a message from the firing behavior and orient itself appropriately, or are you saying I should stick my current code block of
"Create/recycle at this position;
Rotate this direction"
And stick that in a custom block to be used in the same place in the firing behavior?

Zersixs

  • Posts: 14
Search (Rotating) in the StencylForge, there is some custom made behaviors that work's perfect!