Potential Bug Gravity + Friction = No Enemy Movement?

Bane

  • Posts: 42
Hi guys - I was creating a platformer and wanted my enemies to be able to move.

I set the gravity for the scene to 85, and the enemies have a high friction (though any friction causes slowdown)

I then built a behaviour which is at its core the same as the back and forth tutorial behaviour (set x-speed = speed)

Problem is, the enemies do not move far before friction causes them to come to a halt. Setting friction to 0 makes the player able to move the enemies (which is bad)

So Stencylers, what do I do here? Is this a bug? (I don't get why a Y force (gravity) is affecting X forces (x-speed). I don't get why Always x-speed = ## doesn't bypass any of these other things)

coleislazy

  • *
  • Posts: 2607
The gravity pulls the actors into the tiles and friction causes speed loss. Even though you're changing the speed, the loss is still greater. You should be able to use a normal friction, and set the enemy actors to "Cannot be pushed" on the physics tab.

Bane

  • Posts: 42
Not so: Setting things to 'cannot move' or 'cannot be pushed' disables gravity entirely from them. This is problematic.

Epic428

  • Posts: 1118
You could also use this block. Applying a force continuously will force the actor to move how you want.



James Moore - Official Support & Documentation.
We cannot and will not respond to PM's asking questions. Please make a new thread in the forums if you have any questions, Thank you.
For better support and faster response times, please post your logs regarding any Stencyl related issues. Debug > Logs > Generate Logs

Bane

  • Posts: 42
You could also use this block. Applying a force continuously will force the actor to move how you want.





Nice, but messy. I was thinking something along the lines of the following (Let me know if this is possible - I am new to this and not a coder)

If enemy is colliding with tile = true
gravity off
otherwise if enemy is colliding with tile = false
gravity on

(this wouldn't be messing with forces or friction and allow enemies to go from platform to platform accordingly)

Greg

  • *
  • Posts: 1260
In your original example are you setting the x speed every frame or just once?  If you are doing it every frame and it still doesn't work, does increasing the x speed to counteract the friction help?

Greg

  • *
  • Posts: 1260
I tested with an Actor that had friction cranked all the way up to 1.  As long as you set the x-speed every frame (always wrapper block) it should work fine.  If you just set it once (in "when created"), then yes the friction will slow it down.

Bane

  • Posts: 42
*facepalm* I should have known that was the case when I was asking why an always variable wasn't overriding gravity. Some days I have blonde moments, apologies.

So now that this is fixed, I've setup the following:

Always
set x-speed to (speed) for self

When this collides
if left side hit
set (speed) to 5
switch animation to (facing left) for self
if right side hit
set (speed) to -5
switch animation to (facing right) for self

Is there something better I should be doing with the speed attribute? Maybe make speed hidden, but make a second attribute which isn't that will have the values speed is relying on?