Position of FPS gun component inaccurate?

I’m trying to position my bullet to my barrel’s position in my FPS gun system. However, the position of my barrel is extremely inaccurate. At points, the y coordinate of the barrel is negative, despite the player’s camera being above ground. How could I fix this problem?

Example:

2 Likes

Bump – Minimum characters needed

1 Like

Use attachments. Put a attachment at the end of the barrel and use that instead.
Also, maybe the ground is below -100 y axis. The ground doesn’t mean 0.

I’ve already tried using an attachment and the same issue prevailed. The position of the attachment was the same as the position of barrel, therefore the attachment didn’t change much.

There is no problem at all then, your ground is probably near -100 on the Y axis. Just check your ground position.

I had to do something Similar for my games gun system, i just used an attachment put at the barrel of the gun then referenced the attachment in a script and used WorldCFrame to read the position.

How do I change my ground position?

Tried this exact thing and the problem stayed. I don’t really know why it’s happening.

Well, what are you using as the ground? the baseplate? And really, there is nothing wrong with having negative Y axis. If your game breaks on the negative Y axis, then your code is just bad.

1 Like

Assuming you are working on a baseplate just move it up.

Just checked my baseplate, and has been at 0,0,0 this entire time.

I understand that there is no problem with having a negative baseplate. What I don’t understand, however, is that the player’s barrel is positioned above the baseplate(which has a position of 0,0,0) and yet has a y coordinate less than 0. Therefore, when I position the bullet to the barrel’s position, it will be under the baseplate. I’m trying to figure out how to solve that issue.

Did you check the WorldCFrame of the barrel? The normal CFrame parameter is in Local Space relative to the parent. So the barrel position could be negative in local space but positive in World Space

How would I check that?
–Minimum characters

Make sure the viewmodel is anchored, this problem has happened before due to acceleration.

1 Like

Wow, that fixed the problem. Thanks!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.