Jump to content

Applying velocity to a physics object...?


Dealman

Recommended Posts

I'm trying to create something similar to shooter, but in that you can fire objects instead. However, I seem to have hit rock bottom. And I believe the issue is because they are physics objects and because of how MTA handles them.

Whenever a physics object is created, it's frozen solid in the place it was created. And physics won't be enabled until something hits the object. And as such, I can't seem to use setElementVelocity on that object - it doesn't move at all.

And yes, it's created Client-Side, so setElementVelocity should work on objects.

It's even more troublesome because there ain't no function, at least as far as I'm aware to enable the physics. Unless there's some element data for it - which I doubt.

I've tried to use these functions;

setElementFrozen 
setObjectBreakable 

But neither of them seemed to toggle the physics on the object.

Any help regarding this would be greatly appreciated...!

Link to comment
First get your x,y,z coordinates and then use moveObject ( adding some values to x ) and destroy the Object after 3 seconds. Its really easy to make, trust me. ;)

It won't work as well with moveObject though, since it's basically like interpolateBetween. The object will just move from Point A to Point B in a straight line - it won't look like it has physics at all. Just stale, and awkward.

It should be possible to use setElementVelocity on objects, as stated by the wiki. But the MTA Devs probably didn't think it through with physics objects - dunno...

Edit:

Noticed that the object's mass when created is -1. I tried to set it to a proper value, physics remain toggled off for the object. Is there any way whatsoever to toggle the physics other than ramming the object...? :shock:

Link to comment
Well thats right, theres no physics. Requires a lot of coding if you want to make this.

Some objects in GTA have physics, but they are disabled when you create the object. The physics are first enabled when the object is interacted with.

IE, the barrels have physics.

Link to comment
Maybe we can get the velocity by moving the Object to some values and then using getElementType and finally we might be able to use getElementVelocity or its just too much complicated to understand.

I don't think you quite understand what I'm trying to do.

Either way, I tried to create the object server-side to then use getAllElementData on the object to see what datas it had, in case anything would be related to the physics. However, this function doesn't seem to be working at all, at least not for objects. Doesn't return anything. :?

Link to comment

ehm, do projectiles have physics then? They also fly directly by the line, without any boost or speed changes. So you can do the same with objects and it won't be different. As Saml1er said, moveObject + explosion will be enough. Just get the position of the object each frame and calculate if someone is over it to toggle explosion there.

Link to comment
ehm, do projectiles have physics then? They also fly directly by the line, without any boost or speed changes. So you can do the same with objects and it won't be different. As Saml1er said, moveObject + explosion will be enough. Just get the position of the object each frame and calculate if someone is over it to toggle explosion there.

No, they don't but that's a whole other thing though.

If I were to use moveObject, that would mean objects can move straight through other objects. Unless I make some unnecessarily complex workaround for it to be destroy if it enters some other object. And I don't want my objects to explode.

The whole point is for the object to interact with the surroundings, which physics objects do. I just need a way to toggle their physics.

What about creating a vehicle (e.g. a flower pot), applying zero alpha to it, attaching some object to it and then set it's velocity?

I guess it could work, I'll give it a try later to see how it behaves.

Link to comment

Dear Diary,

I have tried a method suggested by a forum member by the name of DakiLLa. So far, the test results have been varying. It seems like it might work.

I am currently trying to find a vehicle that is of appropriate size, and immediately after creation - set its alpha to 0 and remove it. It seems like the object then get its physics enabled since it's already in motion.

However, it does not seem to be doing what I want it to do... Yet.

More testing is needed. I remain curious as to what the results will be.

-- End of Silly Mode --

Edit:

It would seem as though the object needs to be frozen for it to work like intended. I am rather confused. I might have to use moveObject after all, or apply force on collision manually via a function.

Decisions decisions.

Link to comment

I have already achieved what I wanted. The method suggested by Dakilla worked surprisingly well with some tweaks. Basically create the object, and then a vehicle(client-side) at the same location, attach the object to the vehicle and apply velocity to the vehicle. You then simply destroy the vehicle and the object will have its physical properties enabled.

Just some trigonometry needed to make sure it's sent straight forward at all times. :D

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...