ActionScript 3.0 :: Math Friction Over Time
Aug 19, 2010
I'm used to applying basic friction like this:[code]The problem is I don't know how to convert this to be described over time, so that can reduce the value based on the amount of time that has passed.Say I want to reduce the value to compensate for 1 second passing, or 500ms? How does that work in to the equation?
View 9 Replies
Similar Posts:
Nov 10, 2007
I have a billiard ball system, whic detects collisions between balls and modifies their x and y velocities accordingly.I have included a friction variable and I have a very basic system for applying the force of friction for each iteration of movement:
private static var FRICTION:Number = 0.94;
public function move() : Void[code]....
This works to a reasonable level of satisfaction, but it doesn't quite feel right. The balls seem to take just a little too long to stop when they've slowed down to a very small velocity. I've tried tweaking the friction constasnt, but I still can't get sometthing that feels exactly right.
View 3 Replies
Nov 11, 2010
i have a problem with Math.random().here is part of the code:
PHP Code:
//FIRST PLATFORM
if (P1.vy > 0 && d1 <= 0)
{[code].....
as you can see i have Math.random twice, and 99% of the time they return the same value...
View 7 Replies
Mar 7, 2011
Here is the problem:
var p:int = 0;
var n:Number = 0;
n = 32.999999999999999;
p = Math.floor(n);
trace(p); // returns 33
n = 32.11111111111111;
p = Math.floor(n);
trace(p); // returns 32
I would expect both of these to return 32. I have searched, and it seems this is an unreported bug in AS3. Or ... am I doing something wrong?
View 4 Replies
Sep 26, 2005
Wat is the diffrence between these two?
View 2 Replies
Apr 23, 2009
I'm attempting to make a racing game. I want to make it so the user has press two other keys alternately in order to speed up. While the user is not pressing those keys the player should slow down gradually. I'd also like to add friction. Right now, I have code for basic movement:
[Code]...
View 1 Replies
May 10, 2010
I for the life of me can't figure out this simple equation that I want for a camera-following function.As distance decreases, friction increases.Friction being a number between 0 and 1, where friction = 1 is no friction.
View 2 Replies
Feb 16, 2009
I have a code in which I have to use Math.round if a certain value is for example 3.67 (67 is higher than 50) and Math.ceil if a value is for example 3.23 (23 is lower than 50). What can I do to make flash calculate if what after the dot �.� in 3.23 (for example) is higher than 50?
View 2 Replies
Jul 31, 2005
I wrote this 9ball game a while back (never really finished it), and was showing it to a friend today. When a pool ball is rolling fast, less of it's mass should be touching the felt, therefore, less friction. As it slows down, there should be more contact with the felt, and therefore, more friction. Any realistic algorithm to use to adjust the friction higher as the balls slow down? [URL]
View 11 Replies
Nov 12, 2009
when I'm running and not holding my keys down then the friction should slow me down. That works but the speed never stops at zero. I can't see him moving but I've put a text that draws his speed, because if the speed isn't zero and I'm not pressing any button then he will slide and that doesn't work look here: [URL]
The code in the player I use is:
[Code]....
View 1 Replies
Dec 19, 2005
I have an idea for something at work. I want to have stars hanging by strings from the top of my flash document. if the user mouses over these stars I want the star to lightly swing in the direction the mouse went over at. Almost as if you had a cardboard star hanging from the ceiling and you tapped it with your hand. I know this probably includes friction but my tests don't seem to work out the way I want. Does anyone know how to achieve this?
View 8 Replies
Jan 16, 2004
So here is a piece of code that I have seen used a lot but don't really quite understand:
myVar = Math.min(Math.max(myVar, this.min), this.max);
or some variation thereof. I understand that the function first finds the maximum value of two values then turns around and uses that to find the minimum between two values.why this is done? And how do you know when to use it?
View 3 Replies
Jan 16, 2004
So here is a piece of code that I have seen used a lot but don't really quite understand:[code]or some variation thereof. I understand that the function first finds the maximum value of two values then turns around and uses that to find the minimum between two values.And how do you know when to use it?
View 3 Replies
Jun 27, 2011
I have created a flash 3d racing game which relies heavily on AS3's Math functions (sin, cos, tan, asin, acos, atan). It also makes heavy use of Matrix3D and Vector3D functions. The game works great on a PC, but the cars flip around and display innacurate positions on Mac computers. I know this is an issue due to the note on the Math docs page: [URL]
which states: "Note: The Math functions acos, asin, atan, atan2, cos, exp, log, pow, sin, and sqrt may result in slightly different values depending on the algorithms used by the CPU or operating system. Flash runtimes call on the CPU (or operating system if the CPU doesn't support floating point calculations) when performing the calculations for the listed functions, and results have shown slight variations depending upon the CPU or operating system in use."
how do I get this game to work on a Mac? I've tried using lookup tables and inline FastMath style approximations. But lookup tables still create the same problem, and the inline approximations I have found are not accurate enough for my game. I've also tried rounding values with floating point errors, but that has not seemed to help (in my implementation) either. I think the specific problem is with the use of Math.atan. I have not found an accurate approximation for this.. but I maybe that is not even necessary.
View 2 Replies
Aug 23, 2011
How do I get a random number between 0.8 and 1.2 using Math.random(); ? It would be nice if you explain.
View 1 Replies
Apr 29, 2010
What is math.round() do? In kirupa's Random numbers tutorial, he explained the use of math.floor(), but said round() was for another time. Yet I see that, and not .floor() in use in the random movement tutorial.
View 1 Replies
Mar 4, 2011
Are there any math libraries for as3?
I need primarily statistics and regression formulas.
View 0 Replies
Feb 1, 2006
[Code]....
why is it undefined?
View 4 Replies
Apr 24, 2003
here's where all you math genius' get to help me out. I know that this principal is not difficult and was taught sometime during my highschool years.I need a math formula which reduces the ratio of any x:y to the smallest quanity possible. Basicaly so that the smaller of the two numbers is 1 and the other number is whatever it would be, compared to 1... but, I need it to work for both posative and negative numbers.(I'm the ultimate Math newb.. bear with me)
so. I have x=20, y=20 is 1:1
-20, y=-10 is -2:-1
x=10, y=-5 is 2:-1
ect.
so what is the formula for that?
View 14 Replies
Jun 12, 2009
Envrironment: Flash CS3, AS3 I have a horizontal image scrolling project that I am working on, and it works but is not super smooth, I would like it to be smoother when it scrolls, and realize that this is a function of pixels scrolled over time and the FPS of the document.
Right now I am moving the items 1 pixel at a time on a timer with delay of 8 to get it to scroll at the speed I want. I am moving it at 1 pixel in order to catch exactly when an object should wraparound to the beginning of the scroller to show up again. So I don't know that I can really change the number of pixels moved to more than 1 and still have the images spaced perfectly, which makes me think I need to increase or decrease the FPS and or the timer delay to make it scroll smoother. Right now it is at 30FPS and as mentioned the timer delay is 8. Small changes to the delay is not a problem.
This is one aspect of flash i don't fully understand. I would really like to know how to figure this out so I can apply it to future projects as well without doing trial and error to make it smooth. Can it be function, like a way to figure out I need to move a 120pixel picture 60 pixels in 2 seconds, what should my FPS be and the picture size and movement size and number of seconds can be variables?
View 7 Replies
Aug 17, 2010
this math isn't working well. I'm using it for a rotated drag and drop (of a tone arm on a vinyl, a kind of abstract turntable simulation). Right now it just moves a bit in the middle of the vinyl (values between 21 and 36, is this degree or what unit is this?), but it should move between the two edges. The problem is that I don't know enough about trigonometry functions. Therefore I can't optimize the math for envisaged behaviour. Does anybody have an idea/tip how I can get a bit more control on the math and its effect? (maybe with more trace functions)
[Code]...
View 1 Replies
Jan 12, 2009
Set variable as numbers
var monthly_num:Number = 0;
var ttl_num:Number = 0;
var ttl_rev_num:Number = 0;
// user-entered numbers from an Input textfields
monthly_num = monthly_txt.text;
ttl_num = ttl_txt.text;
// Multiply two user-entered number together to get new result
ttl_rev_num = ttl_num*monthly_num;
Attempts to assign numbers typed into textfields to numeric variables causes errors.
1067: Implicit coercion of a value of type String to an unrelated type Number.
View 1 Replies
Jun 21, 2011
I'm not that good with Math and i have a formula for a that it's universal from what i understood but i dont know how to transform it to work with Flash's Math API.
View 2 Replies
Apr 18, 2010
I'm generating a random number between min and max with this code:return min + (max - min) * Math.random();And it works. However, the random numbers are very little usually between "1 or 3" even if the max is 80.
View 3 Replies
May 17, 2011
I'm starting a project for browsers which requires some complex data processing. The algorithm I'm using is 50-100x faster when accelerated with GPU.
I could use JavaScript, Flash or other technologies with the browser.Is there any way I can access the GPU to accelerate the processing of my math?
View 3 Replies
Jun 3, 2011
Some computationally intensive software are now using the GPU to solve mathematical problems. Now that flash has GPU support, is it possible to use flash to crunch math problems? How would it be done. In other words, does flash expose sufficient low level API to control the behavior of the GPU sufficiently to perform such a task? Example of problems; Find a message with the following hash: 2987432847298374298374982374
View 2 Replies
Aug 25, 2011
How to use math mod function in flex?
calculate like this 7 mod(%) 2 = 1
View 1 Replies
Dec 11, 2011
I think I broke my Flash. I'm using Flash CS5.5, and when I use AS3, any references to the Math class give me errors like this:1061: Call to a possibly undefined method sqrt through a reference with static type Class.1061: Call to a possibly undefined method pow through a reference with static type Class.1061: Call to a possibly undefined method pow through a reference with static type Class.The code in error is this:var dist:Number = Math.sqrt(Math.pow(initPos.x - pos.x, 2) + Math.pow(initPos.y - pos.y, 2));What the heck is going on here? Math is a top-level class, so I don't think I should be getting an error like this. Is it possible to somehow "break" the Math class? If so, how do I fix it?
View 1 Replies
Jul 8, 2009
I don't get it. I know it's Math.random(), but how do U use it. Let's say I want a number between 10 and 70.
View 4 Replies
Sep 1, 2009
Does flash go slower if it has to check on points that are for an example: 6.1873128932 versus: 6?
View 1 Replies