How to make an actor's collision field smaller than it's image?

homelesswombathomelesswombat Member Posts: 73
edited November -1 in Working with GS (Mac)
Boy that would save me a lot of work. And make my games nice and purty.

Comments

  • BeyondtheTechBeyondtheTech Member Posts: 809
    The only way it's possible is by having an invisible Actor that's constrained to the real Actor's position. Size the invisible one smaller and put the Collision Rules in there.
  • ORBZORBZ Member Posts: 1,304
    Ya i thought of that too BT, but what if you have more than one actor? What if they are dynamically generated?

    If they are static i.e. you have a fixed amount of them, you can bind them in your scene layer. But if they are dynamic i.e. created/destroyed on the fly, it gets a lot more complex.

    I don't have a good solution for that as I too have tried to find one.

    The best I can suggest, and this is by no means perfect. Is to use the change size attribute to grow your actor a little bit. The collision rectangle doesn't change when you use change size, or rather, shouldn't. I'm having all kinds of glitches with it on 0.8.2 though, It used to work that way on 0.7.0. They may have changed it.
  • BeyondtheTechBeyondtheTech Member Posts: 809
    I would then do a collision with a magnitude calculation.
  • homelesswombathomelesswombat Member Posts: 73
    I like the Change Size idea, that sounds like it would work really smoothly. Too bad it's buggy in 0.8.2 though.

    To be honest I'm amazed that the collision field and the image are the same thing. If there are any devs reading this, I think the image and the collision field being separate variables should be a standard feature (even if the collision fields are still restricted to being circular and square). Such a feature would adds a lot to games visually and in terms of playability. As it is right now it is really tough to make things look like they are actually touching each other, because there is always this little white space between them (unless the image is perfectly square or circular). From a player's standpoint, you always have to kind of "guess" by eye where the collision takes place, making dodging things, touching things and coordinating movement difficult.

    So if there's a 0.8.3 on the way, pleeeeeeeeease put that in!
  • firemaplegamesfiremaplegames Member Posts: 3,211
    I would do it like this:

    Create an invisible actor, a square or circle the size that you need the collision size to be. This is what the player controls.

    Create your graphics Actor, which has all the art/animations in it. This can be any size.

    Create two global real game attributes called playerX and playerY.

    Within the invisible actor, constrain those two global attributes to self.PositionX and self.PositionY
    Spawn the graphics actor from within the invisible actor.

    Within the graphics actor, Constrain self.PositionX to game.playerX and self.PositionY to game.playerY. If you need to, you can also include an X or Y offset here as well.

    I have used this and it works perfectly.

    Hope this helps!
    Joe
  • design219design219 Member Posts: 2,273
    This is something I would really like to see in a future release. REALLY LIKE TO SEE.
  • quantumsheepquantumsheep Member Posts: 8,188
    It's useful for shooters - smaller collision boxes = more fun! :)

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

  • ORBZORBZ Member Posts: 1,304
    Good idea BT.
  • JGary321JGary321 Member Posts: 1,246
    Groin Shot!
  • homelesswombathomelesswombat Member Posts: 73
    I hear what you're saying firemaple, but that solution is only really feasible if you have a few simple actors. If there are dozens of instances of the same actor as in a typical side scroller level, it becomes a programming nightmare because you'd have to create x and y global variables for each individual actor. And that's not even getting into animations, spawning and everything else that makes a game good. They just need to make image and collision field separate variables within each actor and it makes the whole thing simple.

    I'm interested to hear more from BT. What's a magnitude calculation? How would the programming look?
  • homelesswombathomelesswombat Member Posts: 73
    Also, ORBZ I tried your Change Size idea and it appears that the collision field changes with the size now.
  • EastboundEastbound Member, BASIC Posts: 1,074
    Seems to me that you could make a rule with ALL the parameters needed:

    If there is a collison with object blah
    If object blah.x < self.x+10
    If object blah.x > self.x-10
    If object blah.y < self.y+10
    If object blah.y > self.y-10

    This would essentially work as a 20 by 20 collision box I think. It's like a square magnitude function.
  • ORBZORBZ Member Posts: 1,304
    Magnitude is another way if saying distance.

    So if when two actors collide you take the magnitude of their x/y positions you should be able to do some math to see if the length is less than the radius.

    However, I'd rather collision rect & image rect be diff attribs.
  • homelesswombathomelesswombat Member Posts: 73
    Okay thanks Eastbound, I get it now. But what if there are multiple instances of object blah? If you constrain objectblah.x and objectblah.y as global variables does Game Salad automatically make multiple instances of those global variables? Or will the system crash because one variable is being constrained to multiple arguments?
Sign In or Register to comment.