### Simple mechanics? (my problem with stencyl)

#### OttOXBerlin

• Posts: 9
Why are not there the simplest queries?
So, of course, "if over Actor A (actually 32 pixels) a Tileset or another actor" (or more specific) then do not the following ..
not possible .. why not?

Or Scene ... Query:
Are there more than 10 of certain actors in the current scene?
also not possible, I had to go complicated, namely to create a game attribute and to install this in EVERY event of the actor and count. grrr

I just want to use old simple Game mechanics, a wall piece which in only 4! directions
namely if the player so a certain actor touches him
4 !!! not all 360 degree directions ... I turn this around, then my wall piece loses the collision query with the tileset and goes through walls ... and install by hand is not .. wtf!?!?!?!

I have made a small video, but in German sry where I present it
At some point, the video breaks off, got in the moment a blue screen XD

« Last Edit: October 07, 2019, 12:28:08 pm by OttOXBerlin »

#### Luyren

• Posts: 2186
My german is very limited, and your video quality is a bit difficult to read your blocks, but I think I got what your issue is.

You can move that actor around because it has low mass, and it's being pushed by the physical collision between it and the player.

An actor set to cannot be moved, if forced to move as you did, will not be stopped by physical interactions, such as collisions, including with tiles. The player can move that actor because you are setting its speed directly after the collision is detected.

What you want to do is set the object that the player will push to a very high mass. Open your actor, set its physic mode to " Normal", go to the " Physics"  tab, and set its mass to something like 1000 in the Heaviness tab. This should prevent your player from moving your actor from the directions you don't want. If you use the " push actor"  block, you will need a higher force to compensate for the higher mass, but if you set the speed directly, you can use your regular values. This is explained here in more detail.

As for your use of game attributes: you can create behaviors instead, and attach those to your actors., using regular attributes instead. Read about them here. Their attributes are exclusive for each instance of your actors, so one won't affect the others.

In short: your problem is a physics one, not a coding one.
My Stencyl resources are available here: https://luyren.itch.io/
Cutscenes, RPG Elements, Particles, Map System and many more.

#### OttOXBerlin

• Posts: 9
At first... thank you
thank you for reading, listening and try o help <3

now, i have test some things, then i read your post and test it out with the mass... two "ideas" .. it works.. but...
dont solved the problem to make some puzzle into the game without problems...
if there a 4 way movement with moving only 1 tile (32x32 tileset)?!
push the actor exactly one step on the map... is this possible with this stencyl stuff or needs a own code?
can i write or found somewehere a code and use it in stencyl?

okay, i have made another vid an 3 screenshots...
this time only 3 minutes XD

ääähm.. dont notice the Taler_T and Points_T Attributes.. itr was for testing if the Events wascall / use.. want to see it ...
forgot to delete this...

« Last Edit: October 07, 2019, 04:07:21 pm by OttOXBerlin »

#### Luyren

• Posts: 2186
if there a 4 way movement with moving only 1 tile (32x32 tileset)?!
push the actor exactly one step on the map... is this possible with this stencyl stuff or needs a own code?
can i write or found somewehere a code and use it in stencyl?
Under Actors > Tweening, there is this block
Set it to slide by your tile size in the direction you want. So to move up, slide by X= 0, Y= -32. To slide down, X= 0, Y= 32. Right is X = 32, Y= 0 and Left is X= -32, y= 0. The slide block will replace the push block you are currently using.

From your screenshots, you created your movement code inside your actor's events, then copied that. Don't use game attributes, create a behavior and attach it to your actor (Click "Create New", select Behavior, set it to Actor Behavior and name it). There is no need to create a copy of your actor for each one you want in the scene. Only one should suffice, and you can have multiples of that one on your scene.

I am assuming in your game you have to move the boxes to the correct positions, I'll go ahead and provide an example of how to do that just in case. There are several ways to do that which do not require game attributes, and I think this would one of the simplest:
You could have an invisible actor at the point where the box should be to finish a stage, and once it detects a collision, it calls a trigger to a scene behavior that increment a number. You then have an attribute configured to the number of spots the scene has, and when it is equal or greater, you win that stage.
My Stencyl resources are available here: https://luyren.itch.io/
Cutscenes, RPG Elements, Particles, Map System and many more.

#### OttOXBerlin

• Posts: 9

Under Actors > Tweening, there is this block
Set it to slide by your tile size in the direction you want. So to move up, slide by X= 0, Y= -32. To slide down, X= 0, Y= 32. Right is X = 32, Y= 0 and Left is X= -32, y= 0. The slide block will replace the push block you are currently using.

ohh .. I'm so blind. that's embarrassing
youre great man, thank for helping this noob here XD

I'll shoot you a beer or whatever you like to drink XD

#### OttOXBerlin

• Posts: 9

aaaaaaaaaaaahhhh
sorry but look this one, its so... funny

*facepalm*

#### Luyren

• Posts: 2186
You need to add a boolean check on your collision code. Add an IF block covering your entire collision event. It should be:

Code: [Select]
`If <not<CollisionA>>---If bottom collision---......---If top collision---etc`
That is because the collision event executes for every frame while the collision occurs. So it's executing the "slide by" block multiple times before your actor stops colliding with it. Add that, and I think your problem should be fixed.
My Stencyl resources are available here: https://luyren.itch.io/
Cutscenes, RPG Elements, Particles, Map System and many more.