I attached a .c3p file to explain: https://drive.google.com/file/d/1yOEDMwqyTAHCv8PXp8HePV6ddCtQpAll/view?usp=drivesdk
How this program works:
When I click, an “bullet” object is created at the mouse x and y, and z coordinate -100. The created object doesn’t line up with the mouse cursor.
How I want this program to work:
When I click, an “bullet” object is created at the mouse position in screen space— it can have whatever x & y coordinate in world space— and z coordinate -100.
When I click, I want the bullet to appear underneath my cursor.
The working program would look like the image attached.
I’m guessing that the solution involves introducing some constants, and modifying “xpos” and “ypos” in the code:
…
globalThis.SCREEN_W = 320;
globalThis.SCREEN_H = 180:
globalThis.SCREEN_W_HALF = 160;
globalThis.SCREEN_H_HALF = 90;
…
if (lMouse) {
var scalar = …
var xpos = SCREEN_W_HALF + (lMouseX - SCREEN_W_HALF) * scalar;
var ypos = SCREEN_H_HALF + (lMouseY - SCREEN_H_HALF) * scalar;
var zpos = -100;
…
I hope you understand what I’m asking for. Thank you in advance if you decide to answer!