Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • CreatiCode
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

CreatiCode Scratch Forum

CreatiCodeI

CreatiCode

@info-creaticode
Unfollow Follow
About
Posts
1.4k
Topics
454
Shares
0
Groups
6
Followers
26
Following
0

Posts

Recent Best Controversial

  • First Person View Cameras
    CreatiCodeI CreatiCode

     

    Prerequisite

    • The Follow Camera

     

    Introduction

    Many 3D games and demos let the user take a “first person view”, as if the user himself is walking inside the virtual world. The user can use the mouse to turn around and look at different parts of the world. You can easily create such an experience in CreatiCode.

     
     

    Using the Follow Camera in A New Way

    To create a “first person view”, you can actually reuse the follow camera, but in a different way.

    Recall that to use the follow camera, you need to have a target object first, then you add the follow camera to follow that target. Here is a typical example:

     
    When you run this program, you can turn the camera to look at the avatar from different angles, so the user feels like he or she is not the avatar, but watching from behind the avatar.

     
    To look through the eyes of the avatar, we can simply move the camera to the position of the eyes of the avatar. To do that, we need to change the distance to 0 between the camera and the avatar. Also, if the avatar’s height is 100, we can assume the eyes are about 86 units from the ground, so we set the “z-offset” to 86 to make the camera stay at eye level.

     
    Now if we run the project, our camera is indeed inside the avatar’s brain and looking behind the avatar’s eyes:

     
    Of course, the avatar’s head is blocking our camera, so we can’t see anything else. To fix that, we just need to hide the avatar itself:

     
    Now we get a perfect first person view. As we turn the camera around with the mouse pointer, we are no longer looking at the avatar, but at the scene around us instead.

     
     

    Use a Transformer Instead of An Object

    Instead of an object like an avatar or a car, you can also choose to use a transformer object. This is handy when your project will stay in the first person view all the time.

    Since a transformer object is not visible, you don’t need to hide it anymore, and it will load much faster than an avatar. However, you do need to move it to the correct height in the Z direction.

     
    You will get the same first-person view as the previous method.

     
     

    Lock the Mouse Pointer to the Camera

    In the program above, to turn the camera around, we have to press the mouse button and drag the pointer on the stage. However, sometimes we want to allow the user to use the mouse buttons for other types of interactions, such as picking or shooting.

    Therefore, we can “lock the mouse pointer”, so that the camera will turn as the user moves the mouse pointer without pressing down any mouse buttons.

    You can use the following block to lock or unlock the mouse pointer. Select “Yes” to lock and “No” to unlock.

     
    For example, let’s add it to the program from above:

     
    Now if you click the green flag button, the mouse will become locked: the pointer will be hidden, and the camera will turn as you move the mouse. Note that you can press the “ESC” key on the top left of the keyboard to unlock the pointer manually, and click anywhere on the stage to lock it again.

     
     

    Use a “Start” Button to Trigger the Lock

    It is often better to use a button to trigger the pointer lock. It will give the user an option to choose when to enter the locked mode, and also the pointer will be in the center of the stage when it enters the locked mode.

    Here is an example program. When the “Start” button is clicked, we first hide that button, then lock the pointer:

     
    Now the mouse will only become locked after you click “Start”:

    3D Blocks

  • ChatGPT AI - Ask Me Anything! (Difficulty: 1)
    CreatiCodeI CreatiCode

    Introduction

     

    This is a very simple tutorial that shows how to use the ChatGPT block to create a virtual character that can answer user questions.

    simplechat.gif

     
     

    Step 1 - A New Project

     

    Sign in to the CreatiCode playground, and create a new project. You can name the project “Ask me anything”.

     
     

    Step 2 - Add Sprite and Backdrop

     

    You can pick any sprite and backdrop for this project. For example, a professor sprite and a library backdrop. Drag the sprite to the left to leave more space for the speech bubble:

    8a5c6dcc-daf5-4216-a75c-418018d05938-image.png

     
     

    Step 3 - Ask and Wait

     

    When the green flag is clicked, the sprite should ask the user to input a question. We can use the “ask and wait” block like this:

    b73188c5-9ccd-4d09-a240-82b14a1aa9a9-image.png

     
    It should look like this when you click the green flag button:

    7a4b2b24-ec03-46b3-96ed-cbdec059fb8a-image.png

     
     

    Step 4 - Get ChatGPT’s answer to this question

     

    After the user inputs a question and presses the ENTER key, the user’s input will be stored in the “answer” block. Note that it is called “answer”, but in this case, its content is actually the question from the user.

    We will then send this question to ChatGPT and wait for its response:

    09d2d035-3e6e-4d4d-bf07-3d8fe32d553e-image.png

     
    Explanation of the parameters:

    • Request: the “answer” block is sent to ChatGPT as the request.
    • Result: the response from ChatGPT will be stored in the “result” variable.
    • Mode: the “waiting” mode means we will not run any block below this block until the full response from ChatGPT has been received and stored in the result variable.
    • Length: We are setting a maximum length of 500, which means if ChatGPT’s response is too long, it will be cut off. Note that this is 500 tokens, so approximately 375 English words, since tokens can be a part of a word.
    • Temperature: We are using a high temperature of 1, which makes ChatGPT more creative.
    • Session: We are starting a new chat session, so there is no conversation history.

     
     

    Step 5 - Say the Response

     

    After the response from ChatGPT is stored in the result variable, we simply need to make the sprite say it with a speech bubble like this:

    4d185ecb-6a2c-4c47-8399-55e0e3f3a649-image.png

     
    This is the final result:

    simplechat.gif

     
     

    Additional Challenges

     

    Here are some additional challenges for you to try:

    • Shorter Answers: Try to make the sprite give very short and concise answers each time. For a hint, changing the token limit won’t help, and you need to modify the request that is sent to ChatGPT.

    • Continue the Conversation: Currently, ChatGPT does not “remember” previous questions and answers. You can change it by adding a new stack of code: whenever the sprite is clicked, ask the user to input a question, but when you send it to ChatGPT, use the “continue” session type.

    • Different Tones: Currently, ChatGPT generates its response as “a helpful assistant”. You can change its tone to match the sprite you have chosen, such as a professor.

    Tutorials
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • CreatiCode