bullet moves off from position when fired from a different location

Hi,

When firing a bullet it fires on target from the gun, how ever when moving to another location in the scene, the bullet doesn’t fire from the gun, but further away. I tried positioning the empty, I had to do so to get the bullet firing accurately.

I don’t know what could be causing that?

I took a look at another file I have, and the bullet does fire better, it can be a little off if moving rapidly.

Attachments


you can’t use an animation for bullets

best to use a static that moves forward, the same distance it casts a ray each frame, or rigidbody that does the same(but it is a bit trickier)

Nothing has been animated for firing a bullet. Notsure about the ray brick.

I used an old video clip which explains to use motion, always and all that. ‘Borncg’ on the video site youtube.

I tried firing a bullet to a characters head it hits it, but it doesn’t require a collision brick to make it happen. That would be better. Both the head and bullet are both dynamic in the Physics.

First method suggested by BluePrintRandom is the way you should do it. the ray is cast to predict the impending collision. Without the ray, it’s probable, that a bullet would skip through the target.

I only know of one way, the way I made the first weapon I created five months ago when I first learnt of how to create a firing weapon.

So I should delete the brick setup, keep the bullet another layer.

And with no target, the bullet fires off from the empty position, what could be causing that?

I also just noticed a bit of a problem, since I have more than one hand and arm, so a hit weapon, the hit weapon will work fine, but the sound effect of the bullet fire will sound. I still haven’t got a scroll wheel object change setup. Hmm. How can I make sure sounds for one object are for that alone, and so on for others.

https://www.youtube.com/watch?v=vTzsvJe2UfM

You can set your Bullet to be child of the Gun. This way, it inherits the right orientation, when added. The Bullet object itself has to be on invisible layer and contain logic to move on local Z axis(could be something else, depending on your Gun orientation). Now if the Gun adds a Bullet, it’ll start moving the right direction by itself.

I don’t understand the no target situation. But this should not be happening, if you use the above method. So if you replace current logic with what’s described above, it won’t be a problem.

That would be the Arm, since the gun is joined to it.

Right so, change this on the empty, bullet or arm? This ray brick, I parented the gun bullet to the arm, so it a child of that.

don’t parent the bullet, it’s only job is to go forth and kill
a well written bullet does not care who shot it or whom it hits.

add object in a empty parented to the gun should work

This is the brick setup.

So the empty shouldn’t be parented to the arm, well I removed it now. The bullet doesn’t fire.

Attachments



the empty should parent to the arm
the bullet should not be parented to anything and be on a hidden layer

the empty should add your bullet using add object actuator

I tried making the empty the parent, and it then moves the arm as well as the FP. If I parent the arm to the FP, it all messes up. None of it displays when the engine is loaded.

I also found out, by making a hit weapon the parent, and the arm the child, it then knocks objects around, so that was the problem. Is it perfect, not really, from behind an object it didn’t knock one down. The Arm does also disappear once the hitting animation is played…

No parent for bullet**

Bullet is on hidden layer

Empty is parented to armature bone or arm or whatever

when you press shoot the empty adds the bullet from a hidden layer.

please in detail describe what is supposed to happen…
you are confusing.

like

step 1

step 2 etc.

This whole task has turned out to be confusing!

Okay, the bullet is in the third layer, the empty is parented to the arm as the child. The image there displays that empty adds a handgunbullet. The point being as is, the bullet doesn’t fire when the FP is in a different location from the gun of where the empty would be at the nozzle. The other user mentioned using a ray, not using the tutorial clip I had used to make my second shooting weapon since I first used the engine five months ago.

As for the other arm which has a hit weapon, I just found out that the weapon is what hits an object, not the arm, but the arm disappears as it is the child of the parent weapon once the animation sequence plays to hit.

When adding objects ensure the emitting object and all of it’s parents have homogeneous scaling. The best is they all are scaled with (1.0, 1.0, 1.0).

Side notes:

A bullet is typically too fast to be visible, therefore the “ray” method is the recommended way to handle bullets. It requires a tiny bit of Python (to process the hit object/hit position).

Beside of that the Physics engine does not really like small fast travelling objects.

Your method is good at rockets and grenades. They are slow and big enough to work without much hassle.

If you really need a ballistic curve you could use an hybrid solution (see post#2). Have a small projectile but measure with a ray sensor the way before the object. The ray should be as long as the way the projectile will travel within the next frame. It is like you watching your next step. When the ray hits this is the travel ends.

I hope it helps a bit

Using python isn’t an option. It is a brick setup only.

I have also tried while trying this to create a wheel up to change the Arms with different weapons, going nowhere with that.

As for the weapon hit example, the arm vanishes from the location once hitting an object. The weapon hits but the arm doesn’t, before it was the arm that hits and the weapon was no use.

How do i setup this ray for the bullet firing.

If I did leave the gun fire for the moment, it works for the least, it is rubbish. How do I solve hitting and firing at the same time? I can switch to the Arm 2, and there is no mechanism yet, so I just load from the object list. If I use the hit animation, the gun fires bullets and the sound effect is heard.

So how so I isolate that?

[quote=“modelinblender,post:15,topic:674715"”]

Using python isn’t an option. It is a brick setup only./QUOTE]
This is the same extreme approach as trying the do everything in Python. It just makes your work really hard. I guess your issue is the lack of python knowledge. With a little help it should be no big deal. There are a plenty shooting threads out there.

This are “inventory” and “change weapon” aspects and should not belong here. You are talking about shooting.

You mean recoil?

Typically you animate the arm and the weapon at the same time to give the illusion of recoil. This happens after firing (processing projectile or ray).

First fire then recoil.

Ray sensor (from the tip of the weapon) -> Python controller (to process the hit object from sensor e.g. add a force to the hit object, or increase a counter property, …)

I’m confused.

This is how I would do:

The user request the weapon to fire
A) projectile method
firing: add a projectile

B) ray method
firing: either start sensing with the ray sensor (usually you do not turn the sensor off) or checking what is currently hit

Detect an hit

A) projectile
detecting hit: collides with an object
B) ray:
Detect an hit: the ray detects an object

firing and hitting does not occur at the same time. Maybe at the same frame (in case of ray).

The projectile method is already separated. The projectile will exist after firing (never before or at the same time). So it will start sensing within the next frame. Even when you let the target detect the projectile it will do that when the projectile exist only.

The ray method is a bit different. It is usually constantly measuring. The “firing” just tells when to react on the measure - which is “hitting”. Both the measuring object (usually the weapon) and the hit object can react on the hit. The hit object needs to be notified as it can’t detect if something measures via ray (it is not really a ray, it is a line of measurement).

Right okay, for the moment. When I use the hit weapon, the gun sound effect plays, as the left mouse button is for firing a handgun, and using the hit weapon, along with a hand animation.

Obviously, you don’t have all three displayed in the engine, so lets say I have a switch system using the scroll wheel using the brick setup. When i using the hit weapon to hit a character to knock it down or a body party, the gun fire is heard. So how would that be isolated?

The only way I can think off is by using a different key for the hit weapon.

if you make a property for the selected weapon, you can change its vale with scrollwheel and use it to exclude other weapons logic.

You are currently mixing weapon selection with weapon usage.

You need to chose a design that uses one weapon only.

There are several ways to achieve that.

A) have only one weapon
I guess this is the easiest implementation
A1) have only one weapon with several modes
on “weapon switch” you switch mode. This means you change the appearance (e.g. set other mesh) and the behavior of the weapon (play different sound).

B) have only one weapon at the time
on weapon switch you remove the old one before adding a new one

C) have only one weapon enabled at the time
ensure you can enable/disable each single weapon
on weapon switch disable the current one and enable the new one.

D) equip a weapon
have an “usage design” that works with exactly one weapon. All fitting weapons need to be able to work with that design.
On weapon switch disarm the current weapon and arm the new one.
The difference to B) is that the weapon does not react on user input directly. The “usage” talks with the user and the currently equipped weapon. This way not-equipped weapons will not get input for fire (or reload or whatever). The difference to A1) is that you keep a part of the weapon while exchanging a another part. It means the weapon consists of several objects (exchangeable and non-exchangeable).

I hope it helps a bit

Hmm, Considering I’m using the same arms, just with different weapons joined to them, I just want to cycle through and use them with the correct sound. So may be A1?