Ambiera ForumDiscussions, Help and Support. |
|
|
|||||
|
I am trying out (without coding) how to make a player walk more slowly and loose energy by for example carrying more and more stuff. That I seem to manage with variables with no coding. What I can't figure out is: 1) how to meassure the distance a player has walked (a step counter or similar would be handy). If so, I could simply check if the step-variable is more than a specified number or not, and put an action on it. And, perhaps the most difficult: 2) when walking up a mountain/hill, it would be ideal if the player walked more slowly. But how to meassure altitude? Can either of these be done without a javascript? Is there a variable I can use to messure it somehow. Greatful for all help! :-) |
||||
|
Ummm..... well .. you can slow down the player by dexreasing animarion framerate... But without using javascript that would be difficult... Use this to slow down your player... If player has some stuff and let you set a variable for that... For example if player has one stuff Set variable Variable name = stuff Value = 1 Now if player has 1stuff. Use javascript Var player = Ccbgetscenenodefromname ("playernode"); Ccbsetscenenodeproperty (player, 'Framerate', 5); It will slow down the animation to play with 5 frames per second... To measure altitude you can measure the position of your player from scenenode.. and by putting the value of position to a variable name altitude.. You can create a virtual altitude.. Same method can be used for the latitude also,.... Measure the initial position of the player... (Rest position).. And by comparing it with the position of player while moving... You can create a simple altitude and lattitude system... |
||||
|
Hey, and thanks! I already resolved the "movementspeed" with "stuff-variables". But it's good to also be able to change the frame rate - I'll try that! When it comes to the actual distance covered, I just solved it by checking if the up-key is pressed (hold down also works), then the distance-variable get an added value of "1". So, a couple of minutes of walking makes it quite a high number - to be checked by another variable...which slows movementspeed down. The altitude-problem is still there though - what is the variable to use - "position...y"? How to use it? ( BTW, I am NOT a coder so take it easy with me ;-) ) |
||||
|
this is very simple... var player = ccbGetSceneNodeFromName("player"); // change 'player' with your player name. hope it will help you.. now whenever the player is move upwards or downward the altitude will change accordingly and will be drawn on a 2d overlay.. Edit:- As you are a non Programmer i Converted this into a behavior. now all you have to do is to mention the player object and 2d overlay on which you want to display the Altitude. Here is the Download link to the behaviour. https://drive.google.com/open?id... Cheers! |
||||
|
Super - it works like a clock! BUT: I need to fetch the current y-position. Which variable is it? Example: check if y-position of player is greater then lets say the value 10, then movementspeed subtracts with 0.01 I have tried to modify your script with no good results. Also tried to fetch info from player.altitude - just as can be done with player.movementspeed with good results. But no. Noting. Not from player.altitude either, or just altitude. (when should be used?) Please tell me the secret :-) |
||||
|
Just add another line of code in my behavior...
Now you can slow down player by adding an action if a variable has value do something... Variable name = Yposition Is bigger than Value - 10 Execute slow down animation of player... Thats all.. And you can learn a little bit javascript to become more advance in coppercube... |
||||
|
Thanks again, but I actually did just that(!) before, but even with your suggestion (same as mine), Coppercube says : Reference Error - Yposition is not defined How to "define" it? |
||||
|
Ooops... Sorry... Here is the edited last piece of code ... ccbSetCopperCubeVariable('Yposition', this.altitude); All you have to do is add ' ' in the variable name Yposition.... That is silly mistake i always made in my coding... |
||||
|
Brilliant! Works like a charm :-) People like me - artists, script-dyslectics or just hopeless when it comes to scripting - should have polls about the most useful scripts needed in the cube and then pay an amount each for having you or somebody else to do it - a kind of crowdfunding...Up for it? |
||||
|
wow.Good job @just_in_case but,with what you make the behavior? i'm using Notepad++ to Create Behavior but when i'm trying to use the behavior it always saying:Microsoft JScript compilation error how to solve it sorry for Bothering you i'm a Newbie on Scripting i don't have much time to Courses because i must go to School and Many School Work |
||||
|
Ummm... I do use notepad++ to create behaviour and test it directly in coppercube.. by saving it into the extensions directory.. And you are trying to directly open .js file... Thats why you are getting this error... To resolve this issue paste your behavior file in the extensions directory and directly test it within coppercube... Or download javascript environment on your pc... You need javascript compiler to execute javascript file... Google it search for javascript ide and javascript compiler... Hope you understand what am trying to say..! Enjoy your day...! |
|