#how do i make a reloadable gun like this?

1 messages · Page 1 of 1 (latest)

shut sable
#

This is NOT my gun, this was made by god_and_anime. I just want to know how he made a gun like this with the muzzle flash, how he made it so the gun magazine gets into the correct position and how be did the pull back on the back part.

shut sable
#

Lmao im dumb

fervent sigil
#

for the muzzle flash, u can use a point light that increases and decreases in intensity quickly

shut sable
#

alr

fervent sigil
# shut sable This is NOT my gun, this was made by god_and_anime. I just want to know how he m...

for the magazine, u can use the Grabber component if ur using rooms 2.0. otherwise, u will have to either use cv1 or constantly set the position of the magazine using Update. To determine when the player attempts a reload, u can either use Update and constantly check the position and rotation of the magazine (if the reload is succesfull, forcefully unequip the object using the Unequip Object chip), or u can use the On Player Dropped Object event and check the position and rotation of the magazine when the magazine is dropped.

First, get the default rotation from the gun to the magazine (the expected rotation from the gun to the magazine, as in, the rotation when the magazine is when inserted into the gun properly) (I will refer to this as Expected Rotation Offset). The rotation from the gun to the magazine is Multiply(Quaternion Inverse(Gun Rotation), Magazine Rotation) (u can use the Get Rotation chip to get the rotations of the gun and the magazine). Save this value to a Quaternion variable. You will only need to calculate this once, and you can calculate it manually (u will need to calculate it again if the gun model or magazine model changes) and set the Quaternion variable to a Quaternion Create of the resulting values when the player joins.

Next, get the current rotation from the gun to the magazine. You can use the equation I described above to do this. The only difference is that now you are getting the current rotation offset as the magazine may or may not be in the correct rotation (we assume that the rotation you calculated in the previous step is the correct rotation).

Next, get the rotation between the two rotations (the expected magazine rotation offset and the current magazine rotation offset). You can use the same equation to do this. I will refer to this as the Offset From Expected.

#

Afterwards, get the angle of the Offset From Expected quaternion. Get the W component of the quaternion by using the Quaternion Split chip. Get the inverse cosine (also called arccosine or Acos) of the W component by using the Acos chip. Multiply the result of the Acos chip by 2 using the Multiply chip. The result of the Multiply chip is the angle by which the magazine differs from how it is expected to be inserted into the gun. An angle of 0 means the magazine is being inserted perfectly into the gun (u might need to get the absolute value of the angle if it returns a negative result, but im not sure if it does). Check if the angle is within the accepted angle for inserting the magazine by using the Less Or Equal chip (u can choose the maximum angle for Offset From Expected, for example, 15 degrees).

fervent sigil
#

Now you will also need to check the position of the magazine. When setting the Expected Rotation Offset quaternion variable, set another Vector3 variable (I will refer to this as Expected Position Offset) to (Subtract(Magazine Position, Gun Position)) rotated (using the Rotate Vector chip) by the Quaternion Inverse of the gun's rotation when you calculate it. You also only need to calculate this once and can use a Vector3 Create with the resulting values when the player joins (unless the gun model or magazine model changes, in which case, you will need to calculate these values again).

First, get rotated expected offset (I will refer to this as the Rotated Expected Offset). Use the Rotate Vector chip with the input rotation as the gun's rotation, and the input vector as the value of the Expected Position Offset variable.

Next, get the distance between the Rotated Expected Offset added to the gun's position and the magazine. Check if this distance is within a certain range. Less Or Equal(Distance(Add(Gun Position, Rotated Expected Offset), Magazine Position), Max Distance).

If the Magazine's rotation offset is within the maximum angle from the expected magazine rotation, and the magazine's position offset is within the maximum distance from the expected magazine position offset, then the magazine has been inserted into the gun correctly, and you can use the Grabber to attach the magazine to the gun.

fervent sigil
shut sable
#

alr, ill tag later if i have any questions or when i need the pull back

fervent sigil
#

decided to actually hop on rec room for this one (which is why the response took so long, a simple system like this shouldnt take 2 hrs to explain 💀)

#

i rarely ever test the systems i suggest lol (as in, almost never)

shut sable
#

lmao

shut sable
iron forge
#

Trigger volume and animation for the mag, bool switch for the sound and light, and piston for the pull back.

fervent sigil
#

nah i didnt take a picture

#

ask chatgpt to summarize the text

#

u got this bro 👍

fervent sigil
#

but i cant give u any pictures rn

#

if u need any clarification, lemme know

shut sable
# fervent sigil ik i said i would help, so mb lol

hey so i actually asked chatgpt for a simplified version😭 and it gave me this

Step-by-Step Guide
Step 1: Using the Grabber Component
If using Rooms 2.0: Use the Grabber component to attach the magazine.
If not using Rooms 2.0: Use cv1 or constantly set the position of the magazine using Update.
Step 2: Detecting Reload Attempt
Using Update:

Continuously check the position and rotation of the magazine.
If reload is successful, unequip the magazine using the Unequip Object chip.
Connect: Magazine position and rotation -> Update.
Using On Player Dropped Object Event:

#

Check the position and rotation of the magazine when dropped.
Connect: On Player Dropped Object event -> Magazine position and rotation check.
Step 3: Setting Rotation Offsets
Calculate Expected Rotation Offset:
Determine the default rotation of the magazine when properly inserted.
Equation: Multiply(Quaternion Inverse(Gun Rotation), Magazine Rotation).
Save this as Expected Rotation Offset.
Connect: Gun Rotation, Magazine Rotation -> Get Rotation chip -> Quaternion Inverse chip -> Multiply chip -> Save to Quaternion variable (Expected Rotation Offset).
Step 4: Calculating Current Rotation Offset
Get Current Rotation Offset:
Use the same equation as above.
Equation: Multiply(Quaternion Inverse(Gun Rotation), Magazine Rotation).
Compare to Expected Rotation Offset.
Connect: Gun Rotation, Magazine Rotation -> Get Rotation chip -> Quaternion Inverse chip -> Multiply chip -> Save to current rotation offset variable.
Step 5: Checking Angle
Calculate Offset Angle:

Get the difference between Expected Rotation Offset and current rotation offset.
Equation: Acos(Quaternion Split(W component)) * 2.
Connect: Offset From Expected -> Quaternion Split chip -> Acos chip -> Multiply chip (by 2) -> Angle.
Check if Angle is Within Range:

Use Less Or Equal chip to compare the angle to the maximum allowed angle (e.g., 15 degrees).
Connect: Angle -> Less Or Equal chip (compare to maximum angle).
Step 6: Setting Position Offsets
Calculate Expected Position Offset:
Equation: Subtract(Magazine Position, Gun Position) and rotate by Quaternion Inverse of the gun’s rotation.
Connect: Magazine Position, Gun Position -> Subtract chip -> Rotate Vector chip (using Quaternion Inverse of Gun Rotation) -> Save to Vector3 variable (Expected Position Offset).
Step 7: Checking Position
Get Rotated Expected Offset:

#

Rotate Expected Position Offset by the gun’s rotation.
Connect: Expected Position Offset -> Rotate Vector chip (using Gun Rotation) -> Rotated Expected Offset.
Check Distance:

Measure the distance between Rotated Expected Offset (added to the gun's position) and the magazine’s position.
Use Less Or Equal chip to check if this distance is within the acceptable range.
Connect: Gun Position, Rotated Expected Offset -> Add chip -> Distance chip -> Less Or Equal chip (compare to maximum distance).
Step 8: Final Check
If both the rotation offset and position offset are within the acceptable ranges, attach the magazine to the gun using the Grabber component.
Connect: Rotation check result, Position check result -> If both true, use Grabber to attach magazine.

#

ill just @ you if i still cant get it and just ask you to send pictures when ever you get back on (which will proly be 4 years lmaaoooooooooo)

fervent sigil
fervent sigil
shut sable
fervent sigil
#

🗣️🔥

stoic slate
#

real

fleet fog
#

Can’t wait for the response tmr almost everyone wondering how to do this

fervent sigil
#

i alr gave the answer

#

lol

fleet fog
#

Fart I wanna see the pictures I’m way to lazy to read all of it rn

stoic slate
#

lol

fleet fog
#

I’m finna go night night soon

fervent sigil
fleet fog
#

Yes I am that’s why I’m gonna go night night

stoic slate
#

can’t you make it with vector plane or sum ?

fleet fog
#

🤷‍♂️

stoic slate
#

i might be slow ngl

fervent sigil
stoic slate
#

i’ve seen somebody kinda do the same with vector plane

fervent sigil
#

can u explain in more detail wdym by vector plane

stoic slate
#

hollon

#

like this chip

#

i think

#

or another chip similar

fervent sigil
#

yea ik the chip

#

but what do u want to do with it

stoic slate
#

ion know how to explain it

#

brb

fervent sigil
#

ok

shut sable
#

yall im to dumb to figure ts out and plus i should be building this when i actually have my VR headset, if yall want you can try to make it your self and send pictures here.

fervent sigil
#

How much we talking here

#

Meetup bro

#

Also why would u pay for a system that has been explained in full 😭

#

Scamming urself

#

If u wait a lil someone might post a picture

fervent sigil
#

Maybe don’t do that then

fervent sigil
shut sable
fervent sigil
#

Looks like I’m gonna have to give in

#

And send a pic

#

Needa finish the grapher first tho

#

In the meantime tho, I should explain how to make the pullback system

#

Gotta watch the vid again chat

fervent sigil
# shut sable This is NOT my gun, this was made by god_and_anime. I just want to know how he m...

For the pullback on the charging handle, you can use a piston. Create a new Vector3 Variable (which I will refer to as Pullback Offset), and when the player grabs the charging handle, set it to the offset of the player’s hand from the position of the piston, rotated by the inverse rotation of the gun’s rotation. (If u want the charging handle to simply snap to the player’s hands, and not count only the change in hand movement from when the player grabbed the charging handle, set the Pullback Offset variable to (0,0,0) instead). Then, while the player is holding the charging handle, get the value of the Pullback Offset variable rotated by the gun’s current rotation. Subtract the result from the player’s hand position subtracted by the piston’s position. Then, project the resulting vector onto the piston’s direction. Use this resulting vector to calculate the distance the piston needs to extend. You can do this by dividing a component of the resulting vector by the corresponding component of the piston’s direction, for example, by dividing the X component of the resulting vector by the X component on the piston’s direction. You can clamp this value between a minimum and maximum value, to prevent the charging handle from over-retracting or over-extending.

#

Now I alr know ur too lazy

#

And are not gonna even read allat

#

So I didn’t bother listing the actual circuits

#

But I’ll try to finish the grapher and send a pic for u to follow

fervent sigil
#

well now i am

#

😭

#

cant escape chat

echo compass
# stoic slate like this chip

you cant clamp the projection chips as easily. I suggest making projection yourself, or inverse lerp & lerp. Making the projection is simpler tho.

This would be for the pullback mechanism

fervent sigil
#

Yea u just project

#

Then figure the piston extension

#

Then clamp that

echo compass
#

for the magazine, if distance is small enough & vector dot the magazine forward with the gun forward is greater than cos(Cone of how closely the magazine will have to be aligned with the gun), just set its transform to a offset u have predefined via Vector3 Transform or however else ud like to clamp it

fervent sigil
#

Yea u could do it without piston

#

Just need some extra circuits to determine where the piston would be

#

Like with what I did for the magazine

fervent sigil
#

Btw

#

Do u wanna send a pic for these noobs to follow

echo compass
#

yee, projection is just Slider position + Vector3 Scale(Slider direction, Clamp(Dot(Slider direction, (hand position - slider position)), Min meters behind slider position, max meters infront slider position))

for anyone wondering

echo compass
#

but ye, when wake up or sumn

fervent sigil
shut sable
fervent sigil
#

When I finish the grapher I’ll send a pic

#

T55 might send a pic tomorrow

shut sable
fervent sigil
echo compass
echo compass
#

Magazine Part:

echo compass
#

looks fine on mobile. The values are up to u. Im on screen so i made generous: Less than or equal is 0.1, cos is 20

#

also 60Hz is recomended

fervent sigil
# echo compass Magazine Part:

My method is a bit different. The reason it’s a bit complicated is bc it takes the roll of the magazine into account

#

@shut sable ur picture is here 👍

echo compass
fervent sigil
#

I just used a quaternion

#

💯

echo compass
#

idk if quat dot is anything like vector dot, but ye xD

fervent sigil
#

I just got the offset of rotation

shut sable
#

Is the point and rotation on the circuit board just the position and rotation of the vector 3 arrow?

echo compass
echo compass
#

i just use the trigger handle to detect pickup (Alot of the examples are done with convience in mind. Easy to adapt to your own/better way)

fervent sigil
#

With quaternions

#

It’s a bit different

#

But yeah that’s kinda what I’m doing

#

I’ll send a pic when I finish the grapher

echo compass
#

ah alr, So u rotate by inverse then

#

@shut sable

shut sable
# echo compass <@810605652539867137>

ok so the mag part works for it to go in the gun and follow it right but idk how i didnt think about this, how do you make it so the ammo part works. The int wouldnt be the hard part because if you have an int with the same name it doesnt count as the same int variable in the replicator (im building this in rooms 2.0), if i used and event, i would send and event to all the mags on the map which we dont want. so how i be able to make it so the mag detects when its put on, and how much ammo is left in the mag after like 2 shots? i hope i asked that well😭

echo compass
#

anything else seems like basic stuff when mag object enters trigger volume n such & more custom 'clamping' such as setting position n rotation at 60Hz

i thing the muzzle flash is literally just turning a light on n off. Possibly with a delay even

echo compass
shut sable
#

wait i think i might have the idea

echo compass
#

but adapt that to the system better. For instance, ammo element updates based on magazine instead gun index

fervent sigil
fervent sigil
shut sable
#

yes

fervent sigil
#

Then we r finally done here

shut sable
#

real

fervent sigil
#

I really wrote all this just for everyone to go “I ain’t reading allat”

#

😭

#

Gonna have to start sending pics for systems like this

shut sable
fervent sigil
#

I mean

#

If u rlly wanted a system to work u would read through multiple tutorials and documentations until it worked

#

Ppl in circuits channels are just lazy 😔

fervent sigil
fervent sigil
# echo compass Ohhhh xD

I alr made a pullback system and described it to them a while back, but they are “a visual leaner” 💀 so they didn’t read any of it

#

So now we r just waiting for them to follow the picture

echo compass
#

ye xD

shut sable
fervent sigil
shut sable
#

You cant have 2 trigger handles in the same container

fervent sigil
#

I’m confused

#

Also that’s a strange restriction lol

#

Actually nvm it’s not

shut sable
#

Idk im just to lazy honestly😭🙏

fervent sigil
#

Alr mark as answered lil bro

fervent sigil
echo compass
echo compass
#

anything that works for u. but -1 for example bc u want it to go beind instead forward

#

min 😛
remember, behind. So if max is 0 (in line with the slider position) it cant go any farther forward than that

#

Then would be the sum from add else would be the slider position, so when not in use, it "snaps back"

echo compass
#

well, u tried it? Look good from glance. Also instead hand position, use trigger handle position, than u dont have to worry about which hand it should follow (if your gonna keep trigger handle for grab detection)

#

ye thats fine, it will just lag behind which y i use set transform

#

object dont need be grabbable, hide trigger handle by configuring

#

idk, if ur using animation, then the only that should be set transformed is the cube

#

did u make sure the objects pivot is centered?

#

looks like the add adds the scaled instead the vector component position and scaled

#

it should slide along the vector component, trigger handle is to detect pick up to switch from setting back or sliding

#

well, are u gonna use gun or trigger handle?

#

alr, so u have that model clamped on the gun handle already then? (piston makes for a cheaper clamp btw)

echo compass
#

are you concerned with ink? Or performance?

Clamping would save performance
Theres a way to uss a offset constant that will save ink

echo compass
#

o, didnt get notified
So yeah, you would clamp the vector component to the handle & the trigger handle animation to the gun. The set transform should properly handle the slider object. However you will need to adjust the value clamp as -1 will probaly be too far