How to make an actor's collision field smaller than it's image?
homelesswombat
Member Posts: 73
Boy that would save me a lot of work. And make my games nice and purty.
Comments
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.
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!
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
Dr. Sam Beckett never returned home...
Twitter: https://twitter.com/Quantum_Sheep
Web: https://quantumsheep.itch.io
I'm interested to hear more from BT. What's a magnitude calculation? How would the programming look?
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.
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.