Dealman Posted January 5, 2014 Share Posted January 5, 2014 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
Saml1er Posted January 5, 2014 Share Posted January 5, 2014 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. Link to comment
Dealman Posted January 5, 2014 Author Share Posted January 5, 2014 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...? Link to comment
Saml1er Posted January 5, 2014 Share Posted January 5, 2014 Well thats right, theres no physics. Requires a lot of coding if you want to make this. Link to comment
Dealman Posted January 5, 2014 Author Share Posted January 5, 2014 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
Saml1er Posted January 5, 2014 Share Posted January 5, 2014 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. Link to comment
Dealman Posted January 5, 2014 Author Share Posted January 5, 2014 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
Gallardo9944 Posted January 5, 2014 Share Posted January 5, 2014 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
DakiLLa Posted January 5, 2014 Share Posted January 5, 2014 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? Link to comment
Dealman Posted January 5, 2014 Author Share Posted January 5, 2014 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
Gallardo9944 Posted January 5, 2014 Share Posted January 5, 2014 if so, you'd better some something, but not the pot (otherwise you'll have to collide the middle of the object to make it move, rotate, etc), depending on the size and shape of the object. Link to comment
Dealman Posted January 5, 2014 Author Share Posted January 5, 2014 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
myonlake Posted January 7, 2014 Share Posted January 7, 2014 It's way more challenging to script this in Lua than you think it is. It needs more than enough math that you use once in a lifetime. Link to comment
bandi94 Posted January 7, 2014 Share Posted January 7, 2014 moveObject isLineOfSightClear -- colision detection and you could use some Bound function from easing functions when the object hit's the ground Link to comment
Dealman Posted January 7, 2014 Author Share Posted January 7, 2014 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. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now