dragging actors without losing collisions

brantsmith

  • Posts: 151
Hey guys, I have been trying to come up with a behaviors that acts similar to the block sliding puzzles out there on all the app markets (see capture.PNG). However, the one problem I run into, is that if you use set the set X block to move the actors, you completely lose all collisions. In other words, when you move the actor with set X, the actor wont collide with stuff, because you are setting its X directly. Is there a way to move the actors by dragging them with your mouse, and still keep stencyl's built in collision engine. I tried using the "push self gently" block, however, when the block that you are pushing collides with the second block, the first one then pushes the second one with it. Anyone got any ideas.

« Last Edit: May 06, 2013, 07:11:08 am by brantsmith »
Coding is Awesome.
Stencyl is Better.

shotfrost

  • Posts: 221
I think using the push block is a pretty good way. If you don't want the other block to move, just make an behavior that stop it to move if you are not directly target it.
for example, always set it speed to 0 if you don't use it.

Underrated1

  • Posts: 10
I apologize for necrobumping/reviving, but I have a similar problem and would like more information.

For part of a tower defense game I'm working on, a tower that you're deciding the placement on has its coordinates set every frame (sometimes set to your mouse coordinates, sometimes set to your mouse coordinates rounded to the nearest multiple of 16), and it needs to register collisions with certain objects so it knows when you're, for instance, trying to place a tower on the track.

May I ask exactly how I would use the push block to allow for collisions?

h1rnz1lla

  • *
  • Posts: 649
couldn't you reuse the "follow mouse" behaviour and edit it to your needs?

brantsmith

  • Posts: 151
I'm not exactly sure how to solve your problem. but here is what I did. I actually went in and created a collision engine for each block. my game is a grid of 36 (50 x 50) areas. I create a boolean for each square. When I place down a block i set the boolean for those coords to true. then, for each block, I have an always loop that checks for the booleans that are true, finds their position, and sets x and y limits for the actor depending on the position of the booleans. It is a fairly complicated procedure, so i would recommend putting up a new post on the forum and giving more information on what your problem is. but this is a fairly involved procedure. it took me off and on about a 1/2 year to come up with something i was satisfied of
Coding is Awesome.
Stencyl is Better.

Underrated1

  • Posts: 10
couldn't you reuse the "follow mouse" behaviour and edit it to your needs?

Well, well. Why didn't I think of that?  :)

I'll look into that now. Thanks a lot!