how to create a custom collision box. Please Help!
Hello All,
When I have the player collide with an object, the objects hit box is too big. How can I go about creating a hit box which will be close to the shape and size of the object. Hope this is clear enough and if not I can try and explain what I am needing to do another way. Thanks in advance.
Thanks,
killerpenguins
When I have the player collide with an object, the objects hit box is too big. How can I go about creating a hit box which will be close to the shape and size of the object. Hope this is clear enough and if not I can try and explain what I am needing to do another way. Thanks in advance.
Thanks,
killerpenguins
Comments
The area of the square, rectangle or circle is defined by the edges of your image file.
Transparency in an image file has no bearing on collision shape.
Transparency in an image file has no bearing on collision shape or area.
The area of the object is defined by the area of the image file.
When two objects touch, the rule you have applied will happen (the actor is destroyed in your example).
then constrain that actor's X and Y to the box's X and Y
and have Player collide with that actor and not the box
@};- MH
Thanks,
killerpenguins
"then constrain that actor's X and Y to the box's X and Y"
I think it is the other way around, you constrain the main actor to the smaller collision box . . . . ?
(if you want the actor to bounce around the scene that is !)
"I find it annoying that you cant create a precise collision box for each actor."
If your actor is square or rectangular or circular it's trivial (automatic even) to create a precise collision box . . . but if you want a complex shaped collision box you are out of luck I'm afraid.
But . . . if the actor doesn't rotate you can throw a bunch of squares and circles together to create more complex collision areas.
most times circle collisionShape on both actors works best
though think it would be great if collision area was confined to Alpha channel fill.
on the spawnedActor:
Rule: when
Attribute: self.Time ≥ 0.1 … or reference another of that actor's attributes
--spawn the invisible collideSizeActor
leave the options for direction; positions … at 0 and have both Relative to: actor
if neither is moveable, you wont have to constrain
after the collision have the invisible Actor self destruct!
actually, I like not having to define collision areas! … and know I am a majority of one
many other things you can do to control things … with tags and index attributes …
and using magnitude you can skip the collision behaviors and reference that to initiate events/actions
but, that gets yucky for more than a few actors.
@};- MH
"if I am in the object and am wanting to constrain it's x and y to the box which is a different actor, how would I go about that."
The most straightforward way is to create two game attributes (make them the 'real' type) call them something like FollowX and FollowY.
Ok, we have two actors, the main one and the other one which will just be used as a collision area for the main one.
On your collision box actor give it two constrain behaviours:
Constrain the game attribute called 'FollowX' to the collision box actor's position X.
Constrain the game attribute called 'FollowY' to the collision box actor's position Y.
Now we have the two attributes 'FollowX' and 'FollowY' tracking our collision box's every move.
Now on your main actor also give it two constrain behaviours:
Constrain the main actor's position X to the game attribute called 'FollowX'.
Constrain the main actor's position Y the game attribute called 'FollowY'.
Now the main actor goes wherever the collision box actor goes.
GS is easy … but, as you progress to wanting to do more complex things … you should spend some time learning how to.
after 7 days as a member … you should be proud of your accomplishments … but now you should take some of time to sit back and enjoy some video!
if things aren't clearer then or not really what you need/want to do, you know that everyone here will help you …
@};- MH
Thanks,
killerpenguins
fire away with the tweaks you need help with!
1st suggestions
- under sceneAttributes make the sceneSize twice the height of your actual game height
- skip spawning as you want all your actors accessible
- place your actors in the non-displayable section of your scene
- try to have their x positions set
this is bad advice that suits the situation:
-unlock all your actors' behaviors and work in your actors there
-name all there actors even if just using X position as name
-for your actors that are dummy … only used for collisionSize
- add constrainAttributes: and now when you go to the expressionEditor you will see:
Current Scene
select layers and click through till you find the actor you want to constrain it to
you should only need to constrain the dummyActor
next ???
@};- MH
Again, I can't thank you enough for your time and understanding.
Thanks,
Killerpenguins