rotating platform behavior question

sonuvagun06

  • Posts: 54
I have platform actors that rotate around the diameter of a circle, much like a watermill. Because they are not moving along points vertically or horizontally, the "Ride Platforms" behavior and similarly functioning behaviors do not work (credit to Photon for isolating that problem for me).

I've attached the "Rotate Around Actor" behavior. Given that the "Rotate Around Actor" behavior is attached to the platform actor, how can I create a behavior that allows the player actor to "ride" the platform actor without slipping off?

The player actor currently has Platform Movement Plus behaviors attached.

Thanks for the help guys.

flyingninja77

  • Posts: 30
If you're working with Stencyl 2.0 or higher, the following behavior should work.  Please let me know if it doesn't (I've got a more advanced method that might work better).  Note: you are going to need an actor attribute, an actor group attribute, and a Boolean attribute, and the platform should be part of a collision group of moving platforms.

EDIT:  It seems the logic you're using for the moving platform includes setting its location directly as opposed to moving it.  The method I mentioned probably won't work then.  I'll see if I can come up with a behavior that works for a moving platform.

« Last Edit: May 04, 2013, 03:53:10 pm by flyingninja77 »

sonuvagun06

  • Posts: 54
EDIT:  It seems the logic you're using for the moving platform includes setting its location directly as opposed to moving it.  The method I mentioned probably won't work then.  I'll see if I can come up with a behavior that works for a moving platform.

Yeah, that appears to be the difficulty with getting this to work. I feel like I'm missing an obvious solution.

EDIT: I currently am trying to continuously re-position the player actor's coordinates relative to the platform's coordinates. I have a behavior attached to the platform actor: always "set Platform X (attribute) to x of Self, set Platform Y(attribute) to y of Self."  I'm trying to modify a "Ride Platforms" behavior to get the Platform X and Platform Y attributes and set them to the player's x and y... Right now when the player collides with the platform it just resets the player to the top left corner of the scene, (0,0) ...

« Last Edit: May 04, 2013, 05:34:32 pm by sonuvagun06 »

sonuvagun06

  • Posts: 54
Ok,  I think I'm really close to resolving this problem. I scrapped the "Ride Platform" behavior completely. I found a behavior called "Remain Relative to Object" and made modifications as necessary so that it behaved only during collision between player actor and platform actor and when no movement controls are pressed. It works pretty well! Only problem is that when the player actor collides with the platform the behavior places the player at a specific point on the platform, instead of the point of collision. Just trying to work that out.

I'll probably keep working on this all night. If anyone has any thoughts please chime in.

sonuvagun06

  • Posts: 54
Turns out it was a lot simpler than that, actually, half of that code wasn't even functioning. Here are the necessary bits.

So how can I make it so that the player actor sits on the point of collision instead of snapping to x of the parent actor? What I'd like is to have it read so that upon collision, x of the actor is set relative to x of the parent actor, so that when x of the parent actor moves, x of the actor moves accordingly...

Does this make sense?

sonuvagun06

  • Posts: 54
So they way I see it, if upon collision, the difference between the x-center of the platform and x-center of the actor is calculated, and if this difference is subtracted from the x-center of the platform continuously and set to the actor's location, this should give the appearance that when the actor lands on the platform, it stays on the platform at point of collision, not at x of the platform... When I draw it out on paper it makes sense and seems that it would work. When I put it in code the actor just shakes between two points on the x-axis. What am I doing wrong?

If anyone's interested in helping me out with this I'd be more than happy to provide more information.

Photon

  • Posts: 2691
In my most recent game, I have an actor that functions as a conveyor belt. Its not the same, but I think the functionality is similar.

Essentially, have a list attribute to store actors, and then something to store old-x and old-y of the platform. Then for your platform:

When created:
    Set old-x to x of self
    Set old-y to y of self

When actor collides with platform:
    Add actor to actor-list

When updated:
    For every item in actor-list:
        Set x of item to (x-of-item) + (x of self MINUS old-x)
        Set y of item to (y-of-item) + (y of self MINUS old-y)
    Clear all values in actor list
    Set old-x to x-of-self
    Set old-y to y-of-self

That's off the top of my head, but it may be worth a shot.
Do NOT PM me your questions, because I likely will not respond. If I have replied to your question on the forum, keep using that topic. Thanks!

sonuvagun06

  • Posts: 54
Thanks I'l give it a shot. I haven't worked with list attributes yet.

sonuvagun06

  • Posts: 54
Are you storing this entire behavior in the platform actor?

flyingninja77

  • Posts: 30
Turns out it was a lot simpler than that, actually, half of that code wasn't even functioning. Here are the necessary bits.

So how can I make it so that the player actor sits on the point of collision instead of snapping to x of the parent actor? What I'd like is to have it read so that upon collision, x of the actor is set relative to x of the parent actor, so that when x of the parent actor moves, x of the actor moves accordingly...

Does this make sense?

What if instead of finding the X-Center distance of each actor, you found the X (left side) of each actor upon collision and set it to an attribute?  Then you could set (sorry if you're not still using this method) the actor to that X-offset from the platform as it moved.  I haven't tested it out, but that might work.

Happy trails, Flyingninja77

sonuvagun06

  • Posts: 54
Turns out it was a lot simpler than that, actually, half of that code wasn't even functioning. Here are the necessary bits.

So how can I make it so that the player actor sits on the point of collision instead of snapping to x of the parent actor? What I'd like is to have it read so that upon collision, x of the actor is set relative to x of the parent actor, so that when x of the parent actor moves, x of the actor moves accordingly...

Does this make sense?

What if instead of finding the X-Center distance of each actor, you found the X (left side) of each actor upon collision and set it to an attribute?  Then you could set (sorry if you're not still using this method) the actor to that X-offset from the platform as it moved.  I haven't tested it out, but that might work.

Happy trails, Flyingninja77

Flyingninja,

Do you mean setting the offset to the difference between the x of each left side? Because I'm not sure how that would differ from finding the difference of the x-centers. I'll take another look at that later, because it seemed promising, just "off" somehow. Experimenting with Photon's idea now, which, again, seems to be a similar concept with different delivery.

sonuvagun06

  • Posts: 54
Photon, here's what I've come up with based on your description above. It doesn't seem to do anything, how does my code look? It's attached to the platform actor.

Photon

  • Posts: 2691
In the actor list loop, set the x and y of the item, not self (the platform).

Also, unless you only have one platform per scene, I would make those attributes local behavior attributes.

Oh, and finally, you may want to check if the top of the platform was hit in the collision listener.
Do NOT PM me your questions, because I likely will not respond. If I have replied to your question on the forum, keep using that topic. Thanks!

sonuvagun06

  • Posts: 54
Makes sense. I fixed those parts, still not getting a response when I test the game. The platforms rotate around an actor, so they are "Customizeable" in the scene editor. Would this affect the performance of the behavior?

sonuvagun06

  • Posts: 54
I have the oldx and oldy attributes as number attributes. They keep keep coming up as errors in my log:

[ERR] Name: oldX
[ERR] Val: 0
[ERR] {1=false, 2=0, 3=false, 4=false, 5=false, 6=0, 7=No Control, 8=No Control, 9=100, 10=false, 12=true, 13=No Control, 15=No Control, 2147483647=thisactor, 17=0.0, 16=0, 19=5, 18=20}
[ERR] looking for: 206

What does that mean?