|
-
[Solved] AS2 Uphill issues
As the title says, I have an object moving downhil just fine but instead of moving uphill it will move through the hill.
How do I make it move along the uphill slope?
Code:
onClipEvent (load) {
grav = 0;
spd = 1;
}
onClipEvent (enterFrame) {
if (_root.ground.hitTest(this._x, this._y, true)) {
grav = 0;
this._x += spd;
} else {
grav += 0.3;
if (grav>5) {
grav = 5;
}
}
this._y += grav;
}
Edit: So it wont let me upload an attachment so ima try this
-O-----O <--- there are 2 balls here, gravity makes them fall hitting the downslope.
\........../ They slide down normally and move to the other side.
\\____ // Where the Uphill for each begins. They will pass through the uphill like it was a flat surface. I hope this helps explain what i mean.
If not please ask for more description.
Last edited by Degraiver; 01-03-2010 at 08:00 PM.
Reason: wont let me upload an attachment.
-
var x:Number = 1; x /= 0;
You need to know the slope of the ground it is traveling on. so it can know what direction to move. Right now, you have nothing to tell it to go up EVER.
-
Oh? I thought:
PHP Code:
if (_root.ground.hitTest(this._x, this._y, true)) {
tells the object its borders.
So how do I tell the object its slope?
-
var x:Number = 1; x /= 0;
You need to keep track of the slope of the ground at all locations. Physics like this takes lots of calculations.
-
=D no uphill coding for me. Thanks i dont wanna spend too much time on this.
-
var x:Number = 1; x /= 0;
Just wondering...what were you trying to do with this? I may be able to write a simple program for you to look at, just for future reference.
-
Well I wanted monsters to spawn at the top of a mountain, and I wanted the hero to run up the hill to fight the monsters, and Vica versa.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|