Shoot in object
#1

I'm using CreatePlayerObject, and I want for the player that has the object created to shot in the object. How can I do that?

OnPlayerWeaponShoot is not called
Reply
#2

Are you sure OnPlayerWeaponShot isn't called? It has a hittype specially for player objects so player objects are supported.
lagcomp must be enabled for the callback to work.
Reply
#3

I mean is not called with hittype object
Reply
#4

There's also BULLET_HIT_TYPE_PLAYER_OBJECT which is what you need to use (in case you didn't already).
Reply
#5

Quote:
Originally Posted by NaS
Посмотреть сообщение
There's also BULLET_HIT_TYPE_PLAYER_OBJECT which is what you need to use (in case you didn't already).
I already use, but the problem is that, when I shoot in the object, the bullets are not hitting the objects, bullets pass through the object
Reply
#6

Quote:
Originally Posted by None1337
Посмотреть сообщение
I already use, but the problem is that, when I shoot in the object, the bullets are not hitting the objects, bullets pass through the object
Do you mean an object without (bullet)collision?
If it really has no collision at all, it's not possible to natively detect it, at least with the callbacks. You'd need to check every bullet's line and determine if the object potentially intercepts with it. But that's not very nice to do manually.

You could use the ColAndreas plugin to create a fake collision where the object is and check if the bullet (ray) hit it.
Even better, if the object has collision but doesn't collide with bullets (like a mesh fence) you can also use ColAndreas (since CA doesn't distinguish between collision types) but use the original object model.

The simplest solution however would be trying another object model that does have collision. I'm not sure which object you use and if it can be replaced, but that would make it a lot easier since you could use OnPlayerWeaponShot.
Reply
#7

Quote:
Originally Posted by NaS
Посмотреть сообщение
Do you mean an object without (bullet)collision?
If it really has no collision at all, it's not possible to natively detect it, at least with the callbacks. You'd need to check every bullet's line and determine if the object potentially intercepts with it. But that's not very nice to do manually.

You could use the ColAndreas plugin to create a fake collision where the object is and check if the bullet (ray) hit it.
Even better, if the object has collision but doesn't collide with bullets (like a mesh fence) you can also use ColAndreas (since CA doesn't distinguish between collision types) but use the original object model.

The simplest solution however would be trying another object model that does have collision. I'm not sure which object you use and if it can be replaced, but that would make it a lot easier since you could use OnPlayerWeaponShot.
Okay, I changed the object model, but how can I do that when I shoot in it to remain on the same position (the object is a ball and when I shoot (if it above the ground) the object falls down - and I don't want that).
Reply
#8

Quote:
Originally Posted by None1337
Посмотреть сообщение
Okay, I changed the object model, but how can I do that when I shoot in it to remain on the same position (the object is a ball and when I shoot (if it above the ground) the object falls down - and I don't want that).
The ball is probably a dynamic object which reacts to physics. That cannot be disabled unfortunately.

You could respawn the object when someone shoots it (DestroyPlayerObject, and then CreatePlayerObject again). SetPlayerObjectPos also resets it in some cases but the object will remain in its state, so just fall again.
But that won't always work, eg. if it is knocked down by other actions or the shot doesn't register (driveby for example).
Otherwise a timer to frequently reset it would also work.

Still not a very good choice. It's a struggle sometimes to find the right model with the right properties. What do you need it for exactly? Can it be any object with approximately the size of that ball? If you find something else, it could be textured if it looks bad.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)