#how do i make a reloadable gun like this?
1 messages · Page 1 of 1 (latest)
u could ask
just sayin
Lmao im dumb
from the looks of it, the gun isnt screenmode friendly
for the muzzle flash, u can use a point light that increases and decreases in intensity quickly
alr
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).
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.
for the pull back on the back of the gun, u can:
too lazy to type all this rn. u got quite a few questions in one post lol (which is fine i think). let me know if u need help with it later
alr, ill tag later if i have any questions or when i need the pull back
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)
lmao
did you take a picture of it because i do not understand the text you sent lmao
Trigger volume and animation for the mag, bool switch for the sound and light, and piston for the pull back.
😭
nah i didnt take a picture
ask chatgpt to summarize the text
u got this bro 👍
ik i said i would help, so mb lol
but i cant give u any pictures rn
if u need any clarification, lemme know
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)
It didn’t shorten it at all 💀
Send pics of ur system and I’ll try to help
ill make it tommarow because its 10pm but if it doesnt work ill send pictures
Alr u got this 👍
Looks like I’m the better gpt
🗣️🔥
real
Can’t wait for the response tmr almost everyone wondering how to do this
lil bro
i alr gave the answer
lol
Fart I wanna see the pictures I’m way to lazy to read all of it rn
lol
I’m finna go night night soon
looks like blud is too lazy for the system then 💀
Yes I am that’s why I’m gonna go night night
can’t you make it with vector plane or sum ?
🤷♂️
i might be slow ngl
wdym
the thing he wanted
i’ve seen somebody kinda do the same with vector plane
can u explain in more detail wdym by vector plane
ok
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.
How much we talking here
Also #1020059680153808977
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
Btw are u done with the magazine part
@fervent sigil i to dumb lmao. look at the message im replying to
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
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
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
Yea u just project
Then figure the piston extension
Then clamp that
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
yee, but piston ink 
I mean
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
^
Btw
Do u wanna send a pic for these noobs to follow
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
gtg bed 😭
i did a lil 3D printer thing & string match algorithm n such, 6:30 xD
but ye, when wake up or sumn
I’m gonna try finish the scratch grapher. I’ll use it to send a picture too
bro im honestly such a dumb cv2 user😭 idk when you gonna send a picture and hell and can be 3 years but thx for helping out this much🙏 😭 🙏
At this very moment, I am rewriting a lot of the code for the scratch grapher
When I finish the grapher I’ll send a pic
T55 might send a pic tomorrow
cool
Just finished rewriting the code for it, so it’s back to working now
couple hours or so from now, in town 👌
Magazine Part:
(Also unequips automatically instead needed unequip)
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
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 👍
ah yee, i didnt read anything 😭
these just purely my thoughts, but to account for roll, i would dot the gun up and magazine up as well
yee, quaternion dot, or euler angle comparison?
idk if quat dot is anything like vector dot, but ye xD
Idk about quaternion dot
I didn’t use Euler angle comparison either
I just got the offset of rotation
Is the point and rotation on the circuit board just the position and rotation of the vector 3 arrow?
ye, its just a old invention i like to use for quick prototyping, makes things cleaner
i only use it bc the vector compent is completly seperate. If u dont use addition objects for the magazine position (which u shouldnt) just use inverse transform to get the offset, put into vector3 create, than transform it to gun position and rotation
ah, so subtracting the mag forward from the expected direction?
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)
Well no
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
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😭
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
dunno, this my only experience with replicator
wait i think i might have the idea
for ammo, when object unequips, just set ammo full, else set ammo 0 bc thats when magazine removed
then update ammo locally, when gun unequiped, set a list<int> (proportionate in size to how many guns) element to ammo if its not equal to local ammo and send the list to everyone else
but adapt that to the system better. For instance, ammo element updates based on magazine instead gun index
When u send an event to all the mags, include which mag u want to receive the event. When a mag receives the event, check if Self is equal to the mag that is supposed to receive the event.
Did it work
yes
Alr now it’s just the pullback system that’s left
Then we r finally done here
real
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
Honetly tho, i aint reading allat😭
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 😔
dis is the pullback#1241135161480052786 message
Ye just for them to actually make it so we can mark as answered
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
ye xD
So the pull back won’t work in rooms 2.0 but idk care anymore because the mag works and that’s all I’m happy about🙏😭
How does the pullback not work in rooms 2.0
You cant have 2 trigger handles in the same container
Why would they need to be in the same container
I’m confused
Also that’s a strange restriction lol
Actually nvm it’s not
Idk im just to lazy honestly😭🙏
Alr mark as answered lil bro
You can mark this post as answered by selecting the "three dots icon" (···), selecting "Edit Tags", and enabling the "
Answered" checkbox.
really the handle is just to detect when its grabbed, i added for convience
U could use animation when they're fixed to hold a invisble ribbon in place n detect when its picked up or use interaction volume n such. Id say insteraction volume personally
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"
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)
are you concerned with ink? Or performance?
Clamping would save performance
Theres a way to uss a offset constant that will save ink
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