Crystal Space
Welcome, Guest. Please login or register.
December 19, 2014, 04:58:01 am

Login with username, password and session length
Search:     Advanced search
9032 Posts in 2046 Topics by 9288 Members
Latest Member: Lorrainewhite
* Home Help Search Login Register
+  Crystal Space
|-+  Crystal Space Development
| |-+  Support
| | |-+  using AddForce()
« previous next »
Pages: [1] Print
Author Topic: using AddForce()  (Read 1699 times)
koocake
Jr. Member
**
Posts: 54


View Profile
« on: February 07, 2006, 03:53:27 pm »

hi there,

 
    if (kbd->GetKeyState (CSKEY_RIGHT))
    {
      car->AddForce(CS_VEC_RIGHT * 4 * speed);
      car->Update();
    }
Logged
jorrit
Administrator
Hero Member
*****
Posts: 1706


View Profile
« Reply #1 on: February 07, 2006, 03:55:26 pm »

hi there,

 
    if (kbd->GetKeyState (CSKEY_RIGHT))
    {
      car->AddForce(CS_VEC_RIGHT * 4 * speed);
      car->Update();
    }

Hmm... Is this a question or what?

Greetings,
Logged
koocake
Jr. Member
**
Posts: 54


View Profile
« Reply #2 on: February 07, 2006, 03:57:39 pm »

Sory about previous post, submitted before i finished writing!

Hi there,

I am using ode, with the following code to try to move my car.
car is an iRigidBody. The car renders fine in the level, but wont move
when CSKEY_RIGHT is pressed. Im not sure if the problem is here or not.
Am i using AddForce correctly in the following code?


if (kbd->GetKeyState (CSKEY_RIGHT))
    {
      car->AddForce(CS_VEC_RIGHT * 4 * speed);
      car->Update();
    }


regards,
Kate Mallichan
Logged
jorrit
Administrator
Hero Member
*****
Posts: 1706


View Profile
« Reply #3 on: February 07, 2006, 04:09:29 pm »

Note that the force is only active for one frame. So probably you either want to supply a much bigger force to have some effect or else you should keep adding the force for a while. i.e. every frame add that force until the key is released.

Greetings,
Logged
koocake
Jr. Member
**
Posts: 54


View Profile
« Reply #4 on: February 07, 2006, 06:27:38 pm »

thankyou.

I am now using a larger force and making it apply as long as the key is pressed, to simulate pressing the car accelerator.
Part of the problem before was also that I had set the density of the car's collider box too high Smiley

Kate
Logged
Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 4.269 seconds with 15 queries.