How to change speed (integer) by 0.2

nir3112nir3112 Member, PRO Posts: 312
I have a attribute (speed) and I want to change it every 5 by 0.2
I did everything right but its not changing anything...because its integer
So how can I change my speed by 0.2???
Plz help!

Comments

  • SocksSocks London, UK.Member Posts: 12,822
    Use a 'real' attribute.
  • nir3112nir3112 Member, PRO Posts: 312
    edited May 2013
    i try this but i need to restart the game every time the speed change i don't know why but the 'real' attribute not changing anything in 'real time' so the speed doesn't changing
  • SocksSocks London, UK.Member Posts: 12,822
    @nir3112

    It's probably something to do with how you have your code set up.
  • LumpAppsLumpApps Member Posts: 2,881
    edited May 2013
    To clarify, integer can only contain whole numbers like 1 2 3 4 5 10 100 etc.
    Real can contain 1.2 1.3 1.4 100.33 1000.33 etc.

    http://www.mathsisfun.com/whole-numbers.html
  • nir3112nir3112 Member, PRO Posts: 312
    edited May 2013
    To clarify, integer can only contain whole numbers like 1 2 3 4 5 10 100 etc.
    Real can contain 1.2 1.3 1.4 100.33 1000.33 etc.

    http://www.mathsisfun.com/whole-numbers.html
    i know that ^_^' but as i said the 'real' not changing in real time
    @nir3112

    It's probably something to do with how you have your code set up.
    i did rule that say
    when speed>0.3
    timer: every 5 sec
    change attribute speed to speed-0.02

    this not working at all in integer (because its integer) and in real its working but the speed doesn't changing when the game is running i need to restart the game
  • SocksSocks London, UK.Member Posts: 12,822
    . . . in real its working but the speed doesn't changing when the game is running i need to restart the game
    You say you need restart the game, what happens when you restart the game ?
  • grimtoothgrimtooth Member Posts: 69
    How is "speed" defined?... If speed is a readout of self.linear.velocity.x then changing "speed" will only change the variable for a 1000th of a second before it looks at self.linear.velocity.x again and resets its-self.
  • nir3112nir3112 Member, PRO Posts: 312
    edited May 2013
    . . . in real its working but the speed doesn't changing when the game is running i need to restart the game
    You say you need restart the game, what happens when you restart the game ?
    When I restart the game every thing move like the speed attribute say but if I change it when the game is running the speed will not change...
    How is "speed" defined?... If speed is a readout of self.linear.velocity.x then changing "speed" will only change the variable for a 1000th of a second before it looks at self.linear.velocity.x again and resets its-self.
    Explain your self ^_^'
  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    What you need to be changing is max velocity. Adjust the max velocity up and down. Changing the speed will not stop the gained velocity the actor already has. It will only change the acceleration not the current inertia.
  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    Do you want to change it by .2 or by .02?
    I see in different posts you have one(question) or the other(code).

    To each their own. If you can only get it working with integers, just multiply by 5 or 50, then where you use the speed, divide by 5 or 50.

  • nir3112nir3112 Member, PRO Posts: 312
    Do you want to change it by .2 or by .02?
    I see in different posts you have one(question) or the other(code).

    To each their own. If you can only get it working with integers, just multiply by 5 or 50, then where you use the speed, divide by 5 or 50.

    No matter I just need to change attribute by 0.2 every 5 sec
    'Integer' not working..
    'Real' change value but it not effect on the actor, if I want it to effect on it I need to restart the game..
    So how can I change attribute by real number without restart the game?
  • SocksSocks London, UK.Member Posts: 12,822
    edited May 2013
    how can I change attribute by real number without restart the game?
    If none of these suggestions are any help to you then I expect the problem is probably something to do with the way you have your code set up.
  • grimtoothgrimtooth Member Posts: 69
    How is "speed" defined?... If speed is a readout of self.linear.velocity.x then changing "speed" will only change the variable for a 1000th of a second before it looks at self.linear.velocity.x again and resets its-self.
    Explain your self ^_^'


    @nir3112

    I was asking for information about "speed". Is it an independent variable or is it a dependent variable. Where does speed get its value from, and does the value of speed change other variables, or do the values of other variables change the value of "speed"?

    Is it a game attribute, scene attribute, actor attribute, or a value in a table or array?

    You say it won't change during game, do you have an actor set up that will display "speed" in number form while playing? Or are you watching for a change in movement of an actor?

    Grim
  • nir3112nir3112 Member, PRO Posts: 312
    How is "speed" defined?... If speed is a readout of self.linear.velocity.x then changing "speed" will only change the variable for a 1000th of a second before it looks at self.linear.velocity.x again and resets its-self.
    Explain your self ^_^'
    @nir3112

    I was asking for information about "speed". Is it an independent variable or is it a dependent variable. Where does speed get its value from, and does the value of speed change other variables, or do the values of other variables change the value of "speed"?

    Is it a game attribute, scene attribute, actor attribute, or a value in a table or array?

    You say it won't change during game, do you have an actor set up that will display "speed" in number form while playing? Or are you watching for a change in movement of an actor?

    Grim

    1. i created actor that change the value of "speed" every 5 sec and i put it on the screen.
    2.it's game attribute.
    i created actor that display the speed and the value is changing but the speed of the moving actor dosn't changed

  • SocksSocks London, UK.Member Posts: 12,822
    1. i created actor that change the value of "speed" every 5 sec and i put it on the screen.
    2.it's game attribute.
    i created actor that display the speed and the value is changing but the speed of the moving actor dosn't changed

    @nir3112

    How does this attribute ("speed") control the 'moving actor' ?

  • grimtoothgrimtooth Member Posts: 69
    edited May 2013
    @nir3112

    Ok! That is exactly what we needed to know!

    Now, delete that attribute "speed", it is just getting in your way lol.

    Changing "Speed" is like changing the time on your clock, if you set the clock ahead 6 hours it won't make it dark outside because the clock doesn't CONTROL time, it just reports the time

    What you are wanting to modify (and dusplay) are the Actor attributes "self.linear.velocity.x" and "self.linear.velocity.y" of the actor whose speed you want to change

    Grim
  • nir3112nir3112 Member, PRO Posts: 312
    @nir3112

    Ok! That is exactly what we needed to know!

    Now, delete that attribute "speed", it is just getting in your way lol.

    Changing "Speed" is like changing the time on your clock, if you set the clock ahead 6 hours it won't make it dark outside because the clock doesn't CONTROL time, it just reports the time

    What you are wanting to modify (and dusplay) are the Actor attributes "self.linear.velocity.x" and "self.linear.velocity.y" of the actor whose speed you want to change

    Grim
    ok i think i understand u , i'll try it(:
Sign In or Register to comment.