PDA

View Full Version : Defining where the ground is


unicycler
12-21-2004, 02:20 PM
I made an area call "ground", where gravity stops when the object is on the ground. My problem is that the ground is not a flat object but the area is a recangle and that is what makes the object stop. I need to know how to change the deffined space of the graphic to its actually shape and not a rectangle.

Freddy
12-21-2004, 06:45 PM
I too had this problem in another game. still dont know how to do it though. I just gave up on the game and statrted another. dont recommend u diong the same though.

edmarriner
12-22-2004, 03:49 AM
yer , i could not do this either so i made it from the side angle.

have a look here (http://www.edmarriner.co.uk/ed.htm)

unicycler
12-22-2004, 03:17 PM
If nobody has an idea how to do it, can somebody atleast help me with what it would be called? I have searched everything that I could think of and still can't find anything that is remotly like a discription of what I am looking for.

Nexus
12-22-2004, 04:41 PM
You mean if the ground were shaped like an oval, keep the object stopped at the edge of the oval?

Using hitTest() is how this is done, though instead of testing two movieclips, you compare a movieclip and an x/y value i.e

//Checks to see if coordinates are colliding with ground
ground.hitTest( man._x, man._y, true )

I'm sure you can figure out the rest from there, it's not that tough of a concept to grasp. The true value supplied at the end just tells Flash to perform a hitTest based on the movieclips shape, not a rectangle like the normal hitTest() does.

unicycler
12-22-2004, 05:55 PM
It still isn't working correctly. Could you please go in to a little more detail of what the surrounding code would look like if I had gravity and wanted the gravity to be 0 when the man hit the ground?

Freddy
12-22-2004, 06:18 PM
I hope it works for me.
I haven't tried it yet but for u wouldn't it be like

if(_root.man.hitTest(_root.ground._x, _root.ground._y, true)){
gravity = 0;
}else{
gravity = [whatever u had];
}

I'm gonna try out my way on my game. later.

bobmasedo
12-23-2004, 06:42 AM
you could assign another hitarea around part of it, but that would be annoying to do every time and it wouldnt work with a round surface, its just another suggestion

Freddy
12-23-2004, 02:11 PM
poopies. it doesnt work.

an my doohicky is round and odly shaped.

unicycler
12-23-2004, 04:16 PM
Ok, well as I look for an awnser to that I would also like to know if there is any way to set multiple rotation points. So if I press the right arrow it rotates around one point, but if I press the left arrow it rotates around another point, and if the guy is in the air it rotates around yet another point.

Nexus
12-23-2004, 05:13 PM
No, you have it backwards. It's supposed to be the other way around. You could put this in the man's enterFrame code....

if( _root.ground.hitTest( _x, _y+(_height/2), true ) {
vx = 0;
vy = 0;
}

This is assuming you have vector variables vx and vy. This could be xspeed or yspeed. Whatever. Just change it to what you have. All the _y+(_height/2) is for is in case the man's rotation point (origin) is in the middle. This way it checks for collision around his feet.

Short of programming the entire thing for you I don't know how I could make this any easier to understand, and that's not something I feel like doing at the moment.

As for your other question, I have no idea. I don't think you could dynamicly do it using actionscript, you'd just have to come up with some fancy way of simulating it by using sin() and cos() functions.