Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Help with CopperCube
How to set movement acceleration by script?

Alireza
Guest
Quote
2021-04-29 23:02:52

I know this feature is present in the" object or person controlled by keyboard " behavior. But I want to create it myself with coding. How?


marcw
Registered User
Quote
2021-05-01 18:23:35

Hello,


Alireza, I am also concerned by that matter for my project "Copperghinator".

That's why I spent my day to create a good demo showing the process of constant speed, acceleration and deceleration.

Here is the link to the zipped folder uploaded on my OneDrive (secured and anonymous access : https://1drv.ms/u/s!AjokN1FU3jK1... ).

The zipped file contains the .CCB and the .EXE files relative to that demo.

The key "Up arrow" accelerates the speed of the cube01.
The key "Down arrow" decelerates the speed of the cube01.

The limits of the covered distance is 150 decimeters in the positive Z direction and is -50 decimeters in the negative Z direction of the cube01.

If the speed of the cube01 becomes negative then it runs towards the negative Z direction.

When the cube01 or the cube02 reaches the positive or the negative limits then it automatically returns to their start point.

I must admit that it was not easy to create that demo and I hope that it works correctly and that it could help understanding the speed and acceleration of a mobile.



COMMENT EDITED ON THE SAME DAY (2021-May-1st - 10PM ) : There was a mistake in the message relative to the "current speed of the cubes". The units are "dm (decimeters)" and not "mm (millimeters)".

I just replaced the previously uploaded zip file by a new one.

I am sorry for that mistake.


alireza
Guest
Quote
2021-05-01 23:28:17

thank s a lot dear marcw.
I download your demo.
it is very very useful for me.
In addition to acceleration, I also needed a speedometer, which I found in your file.
The speedometer is very important for my project. The amount of controllability of the car and the amount of damage during an accident and collision with a pedestrian, etc., all depend on speed.


marcw
Registered User
Quote
2021-05-02 12:09:55

Hello Alireza,

I am very glad to read your pleasant comment.
As mentioned in my previous comment, converting the equations of acceleration and deceleration into a compact algorithm taking into consideration every delta times and delta speeds was a challenge.

Learning mathematics and physics with CopperCube is intellectually enjoyable.

About the speedometer for your project, I may imagine that you could create an analog version with a rotating needle.

Anyway I wish you all the best with the development of your very interesting project.




adteam43
Registered User
Quote
2021-07-11 17:16:12

I create ccb files for moving any vehicle very smooth without javascript only with built-in variables.
Its a little bit messy but its works perfect.


andgameplay
Registered User
Quote
2021-07-14 16:05:34

Hi adteam43, I have no idea how you made acelleration only with variables. Do you have the file with example? I would like to see. Thanks!


adteam43
Registered User
Quote
2021-07-15 11:47:46

Post your email to send the files.

Its very easy to do this but its very complicated also.
Because its only variables and not a script.


veganpete
Registered User
Quote
2021-07-15 13:19:31

wrote:
Hi adteam43, I have no idea how you made acelleration only with variables. Do you have the file with example? I would like to see. Thanks!


You can use variables to do something basic like...

when "accelerate" key is pressed, +1 to {}car.movementspeed
when "brake" key is pressed, -1 to {}car.movementspeed
If {}car.movementspeed >100 , {}car.movementspeed =100
If {}car.movementspeed <1 , {}car.movementspeed =0

You can then add more variables to add complexity.


andgameplay
Registered User
Quote
2021-07-16 01:14:43

Hi adteam43, my e-mail to send the file:

andrewqi_@hotmail.com Thankyou so much!


adteam43
Registered User
Quote
2021-07-16 03:40:26

Ok I prepare the files (full test multiple files) and I will send it to you.
When I send I leave message here.


adteam43
Registered User
Quote
2021-07-16 15:37:58

andgameplay

i send you the files just now in your email.
also with instructions.

if you receive it and study my files feel free to share your thoughts with the rest of the members here.

Thank you


Chris
Guest
Quote
2022-12-19 02:07:31

@adteam43 would you mind to share this solution? Thanks


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Internation?l" (you are not logged in)


Text:

 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


   






Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact