• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
raxell

Choose value for speed and acceleration

5 posts in this topic

Hi, I'm new to the forum.

I read about steering behaviors and I have understood a bit how the entities moves in a game (the position is updated by the velocity and the velocity is updated by the steering force).

In some examples i see that the update function of the entities has a "time elapsed" parameter that is multiplicated for the acceleration and then for the velocty. What is this parameter and is it required?

The other thing i haven't understood is how to choose an appropriate value for the max_speed and max_acceleration (or max_force). What is the relation between this two constants? Should i increase their values if i use the time elapsed parameter?

0

Share this post


Link to post
Share on other sites


In some examples i see that the update function of the entities has a "time elapsed" parameter that is multiplicated for the acceleration and then for the velocty. What is this parameter and is it required?

 

Yes, it is required. Imagine I tell you a car is going with a speed of 50 Km/h, and I want to know how far it has moved. If I don't tell you how long he's been going at 50 Km/h, you can't possibly know the answer. So in order to modify the position using the velocity, you need to know how long the velocity has been applied. Similarly when you want to modify the velocity using the acceleration (which is proportional to the steering force).

0

Share this post


Link to post
Share on other sites

The other thing i haven't understood is how to choose an appropriate value for the max_speed and max_acceleration (or max_force). What is the relation between this two constants? Should i increase their values if i use the time elapsed parameter?

 

You don't say, but I'm assuming you're simulating some sort of vehicle. Regarding max_speed and max_force, I don't know why you would necessarily need either one. The forces on the vehicle will normally come from friction. Friction forces such as wind resistance will increase with speed. Lateral tire friction (the wheels are turned) will act to steer the vehicle through a torque about the center-of-gravity. The propulsion system (e.g., car engine) will, for instance, rotate the tires and, through friction of the tires with the surface, add a force. The maximum speed for the vehicle will likely be determined by those forces, assuming you limit the maximum torque the propulsion system provides. That may be the "max_force" you're thinking about.

 

If so, browse the internet for information on the type of propulsion you have. If it's a car engine, look for maximum torque or horsepower data. Pick an appropriate mass for your vehicle (e.g., browse for curb-weights of various cars) and you're off to the races (pun intended).

 

That is, gravity, wind resistance, and tire friction will slow the vehicle. The propulsion system will provide a forward force, limited by internal friction which is some function of the engine speed* (for instance). The acceleration will be the sum of those forces times the mass. When the resistance equals the propulsive force, acceleration with be zero and the vehicle velocity won't change any more. The velocity will be zero or some maximum speed.

 

*Max engine torques/horsepower can be considered to reflect internal resistance.

 

Sorry if that's a bit wordy.

Edited by Buckeye
0

Share this post


Link to post
Share on other sites

Yes, it is required. Imagine I tell you a car is going with a speed of 50 Km/h, and I want to know how far it has moved. If I don't tell you how long he's been going at 50 Km/h, you can't possibly know the answer. So in order to modify the position using the velocity, you need to know how long the velocity has been applied. Similarly when you want to modify the velocity using the acceleration (which is proportional to the steering force).

 

So the time is calculated each game loop execution and passed to each update function?

Can you say me if something like this can be good?

// number of updates per second, higher = entities moves faster
fps = 100;
// for how much seconds the entities should be updated
duration = 10;

timer = new Timer(fps);
timer.start(duration);

// updates the entities until the script exceeds the duration time
while (!timer.isTimeExpired()) {
    // assert the updates per seconds (fps) are not exceeded
    if (timer.isReadyForNextUpdate()) {
        entity.update(timer.getTimeElapsed());
    }
}

Here's the timer class referred above (it is in php):

class Timer
{
    /**
     * @var float 
     */
    private $startTime;
    
    /**
     * @var float 
     */
    private $endTime;
    
    /**
     * @var float 
     */
    private $currentTime;
    
    /**
     * @var float 
     */
    private $nextTime;
    
    /**
     * @var float
     */
    private $timeElapsed;
    
    /**
     * @var float 
     */
    private $lastTime;
    
    /**
     * @var float 
     */
    private $timeScale;
    
    /**
     * Constructor.
     * 
     * @param int $fps
     */
    public function __construct($fps)
    {
        $this->startTime   = 0;
        $this->endTime     = 0;
        $this->currentTime = 0;
        $this->nextTime    = 0;
        $this->timeElapsed = 0;
        $this->lastTime    = 0;
        
        $this->timeScale   = 1 / $fps;
    }
    
    /**
     * Starts the timer.
     * 
     * @param float $duration
     */
    public function start($duration = 1000000)
    {
        if (!preg_match('/[0-9]+?/', $duration)) {
            throw new InvalidArgumentException('The passed parameter must be an integer!');
        }
        
        $this->startTime = $this->currentTime = $this->lastTime = microtime(true);
        $this->nextTime = $this->currentTime;
        $this->timeElapsed = 0;
        $this->endTime = $this->startTime + $duration;
    }
    
    /**
     * @return float
     */
    public function getCurrentTime()
    {
        return $this->currentTime;
    }
    
    /**
     * @return float
     */
    public function getTimeElapsed()
    {
        return $this->timeElapsed;
    }
    
    /**
     * @return bool
     */
    public function isReadyForNextUpdate()
    {
        $this->currentTime = microtime(true);
        
        if ($this->currentTime > $this->nextTime) {
            $this->timeElapsed = ($this->currentTime - $this->lastTime) * $this->timeScale;
            
            $this->lastTime = $this->currentTime;
            $this->nextTime = $this->currentTime + $this->timeScale;
            
            return true;
        }
        
        return false;
    }
    
    /**
     * @return bool
     */
    public function isTimeExpired()
    {
        return $this->currentTime > $this->endTime;
    }
}

if i add the time than the speed and acceleration constants must be higher?

 

 

 

You don't say, but I'm assuming you're simulating some sort of vehicle. Regarding max_speed and max_force, I don't know why you would necessarily need either one. The forces on the vehicle will normally come from friction. Friction forces such as wind resistance will increase with speed. Lateral tire friction (the wheels are turned) will act to steer the vehicle through a torque about the center-of-gravity. The propulsion system (e.g., car engine) will, for instance, rotate the tires and, through friction of the tires with the surface, add a force. The maximum speed for the vehicle will likely be determined by those forces, assuming you limit the maximum torque the propulsion system provides. That may be the "max_force" you're thinking about.

 

If so, browse the internet for information on the type of propulsion you have. If it's a car engine, look for maximum torque or horsepower data. Pick an appropriate mass for your vehicle (e.g., browse for curb-weights of various cars) and you're off to the races (pun intended).

 

That is, gravity, wind resistance, and tire friction will slow the vehicle. The propulsion system will provide a forward force, limited by internal friction which is some function of the engine speed* (for instance). The acceleration will be the sum of those forces times the mass. When the resistance equals the propulsive force, acceleration with be zero and the vehicle velocity won't change any more. The velocity will be zero or some maximum speed.

 

*Max engine torques/horsepower can be considered to reflect internal resistance.

 

Sorry if that's a bit wordy.

 

 

Sorry, i forgot to say that i'm trying to simulate a football match based on some player skills. Some of this skills are "speed" and "acceleration" represented by two constants (representing the maximum value of the skill). Each player will have a percentage of this constants.

I think speed can be interpreted as how fast a player can travel (when it has reach the max velocity), and the acceleration how much time the player take to reach the max velocity. So, if i have two players with same speed but different acceleration i expect that the player with the higher acceleration will reach the target first (correct me if i'm wrong).

So, the movements of the players should depend by its skills and not only by the enviorment (wind, ecc...).

Edited by raxell
0

Share this post


Link to post
Share on other sites

So the time is calculated each game loop execution and passed to each update function?
Can you say me if something like this can be good?


I didn't read your code in detail, but the best way to handle this is explained in the classic piece "fix your timestep!". You should definitely read it.
 

Sorry, i forgot to say that i'm trying to simulate a football match based on some player skills. Some of this skills are "speed" and "acceleration" represented by two constants (representing the maximum value of the skill). Each player will have a percentage of this constants.
I think speed can be interpreted as how fast a player can travel (when it has reach the max velocity), and the acceleration how much time the player take to reach the max velocity. So, if i have two players with same speed but different acceleration i expect that the player with the higher acceleration will reach the target first (correct me if i'm wrong).
So, the movements of the players should depend by its skills and not only by the enviorment (wind, ecc...).


Do you realize how absurd it is that you were asking us about reasonable values for max_speed and max_acceleration before we knew if your units were fish or alien spaceships?

For football players, you can probably find the 40-yard dash time for lots of them. There are also other distances available. You can also see how people that run the 100m dash accelerate (I found some cool graphs here), which you can try to match by tweaking your max_acceleration and max_velocity numbers.

Using a drag force might be a good way to limit the speed naturally, and then you only need to limit the acceleration.

In any case, playing around with different values until the response feels right for your game is the only way to go about this. And it can be a lot of fun! Edited by Álvaro
0

Share this post


Link to post
Share on other sites

My problem is that I have different results if I use the time elapsed or not (with the same values for speed and acceleration).

I mean the same thing of this post: http://www.gamedev.net/topic/634663-arrive-steering-behavior/#entry5003771

 

For example:

If I don't multiply for the time elapsed (deltaTime) I can use a value for speed like 0.7, but if I multiply for deltaTime the value must change to 70 or higher to see the player moving. But if i use a value like 70 the truncate on the velocity became needless because the velocity will never reach that value.

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0