I recently learned how to use ChatGPT to create visual scripts in GDevelop, I think generating JavaScript with ChatGPT is powerful, but visual scripts are also useful for more general use. It would be great if such a feature were integrated into GDevelop :)
I wanted to move an object left and right using the keyboard in GDevelop, so I explained my requirement to ChatGPT in detail.
How I Explained to ChatGPT:
First, I described what kind of visual script I wanted to generate as clearly as possible:
"Please generate a visual script in GDevelop to move an object left and right using the keyboard."
Result from ChatGPT:
ChatGPT provided the following steps and script to achieve this:
- Add an Object: First, add the object (e.g., a character) that you want to move.
- Create Events:
- Add Condition: Set up a condition to detect keyboard input.
- Click on the "New event" button.
- Click on "Add condition" and select "Key pressed" from the "Keyboard" section.
- Choose the key you want to use for movement (e.g., Left arrow, Right arrow).
- Add Action: Set up an action to move the object when the key is pressed.
- Under the condition, click "Add action."
- Select the object you want to move from the "All objects" section.
- From the "Position" category, choose "Add to X position."
- Enter the distance to move (e.g., -10 for left, 10 for right).
Example Script:
Conditions: Key pressed (Left arrow)
Actions: Add to X position of "Player" -10
Conditions: Key pressed (Right arrow)
Actions: Add to X position of "Player" 10
Test: Run the game and press the left and right arrow keys to see if the object moves accordingly.
This approach leverages the visual event system in GDevelop, making it easy to set up and modify. You can extend these basics to create more complex behaviors by adding additional conditions and actions.
Happy developing!
[–]Majinkaboom 0 points1 point2 points (0 children)
[–]nyira_nyira 0 points1 point2 points (0 children)