Community Forum

Toggle animation without external script.

Forum Overview >> Scripting

CategoryScripting
Created18.04.2017 23:10


Eanna Wood (Unknown) 18.04.2017 23:11
I need to fold my implement. I have added the animation and the folding attribute to the xml but in game there is no option to fold. I am using a defualt vehicle type of dynamicMountAttacherImplement because I can't make my own vehicle type without a custom script which prevents the mod being used on xbox/playstaion?
Hope someone can help.

Emil Drefers (Unknown) 19.04.2017 06:54
Hi,

the foldable specialization should do the trick.

Eventually custom vehicleTypes without any new scripts are allowed on consoles, I'm not sure though.
In this case you only need to create a new vehicleType.

Otherwise you could use the "shovel_dynamicMountAttacher" as vehicleType.
It's too much in the end you you probably would need to add some xml attributes, which are useless in this case.
But it should work.

Cheers,
Emil

Eanna Wood (Unknown) 19.04.2017 14:29
Hello,
Thank you very much for this idea, it works somewhat.
My new creation is a bale spike, and it has two parts two it. So when I lower it down with V and lift it it works fine. But when I press X to fold it the dynamicMountAttacher seems to stop working? It's hard to explain so I will attach a video here.
Notice when I turn on the collision view with F5 you can see that the dynamicMountAttacher col boxes also moved so I can't figure out why I doesn't work. (https://youtu.be/YXO1Fg2mWrA)

My other question, is it possible for me to upload 1 more advanced version for PC/Mac and then a basic version for Xbox/playstation?
Thanks again.

Emil Drefers (Unknown) 19.04.2017 17:36
Hi,

the bales are connected to the "physical body" of your spike with a joint.
As soon as the joint is moved in relation to the "physical body" of your spike you would need to update the "joint".
This can be done by using setJointFrame().
But as you do not want to use a script .... hmmm

So, there is a solution.
Create a second physical body for the "moving arm(s)" of the spike.
Next set the rootNode of the DynamicMountAttacher to the second physical body.
By this the position of the dynamically created joint will never change (in relation to the physical body it is linked to).

That means you need two components ... <components count="2">
Make the folding work for this two components.
And finally you can set the rootNode of the dynamicMOuntAttacher ( <dynamicMountAttacher ...... rootNode=">1" .... /> )

That should do the trick.

But, be careful when you adjust the masses of the two components.
At best they both should have the same weight.

Finally you might get some problems with the joint which connects these two components (it might become losse on heavy load)
But that can be explained later on. Adjusting the weight will help in the first place.

Hope that information helps.

Cheers,
Emil






Eanna Wood (Unknown) 19.04.2017 18:52
Hello,

I understand what your idea, I hope it can work.

Two problems I notice. Firstly I just did it and the item flals apart in the shop :(. It just breaks in half and falls into two piece at the store.

Secondly when I change ( <dynamicMountAttacher ...... rootNode=">1" .... /> ), notice that the bale spike has two sections, one that lifts and one that does not. MountAttacher root to the section that lifts will it not break the section that does not lift? Anyhow the first issue is more important right now.

Also is it possible for me to upload 1 more advanced version for PC/Mac and then a basic version for Xbox/playstation?

Thanks.
Eanna5

Emil Drefers (Unknown) 24.04.2017 06:56
Hi,

ah, I didn't think about having 'two dynamicMountAttachers'.
So, no there is no option to define two rootNodes for the triggers.
I guess we should implement that somehow in the next version of FS.
Seems like you would really need a custom script to make your spike work correctly.

Not sure if it would be possible to upload two different versions.
Please contact the team of the ModHub to get that an answer to that question.

Cheers,
Emil



Eanna Wood (Unknown) 24.04.2017 22:52
Thank you,
That leaves me with no option, I will have to forget about Xbox and PS and write a script.

I can't find anything for "setJointFrame()", I assume you mean "setComponentJointFrame()"
Can you think of anywhere I can find some examples for the setComponentJointFrame() method? It is hard to understand from the documentation seen as not much info is given in the description.

Thanks

Emil Drefers (Unknown) 25.04.2017 06:49
Hi,

well Vehicle:setComponentJointFram() uses setJointFrame()
https://gdn.giants-software.com/documentation_scripting.php?version=script&category=69&class=3534#setComponentJointFrame47932

Let's explain it on an example:
setJointFrame(jointDesc.jointIndex, anchorActor, jointNode);

First argument is the identifier of the joint (which has been returned by the joint constructor).

Second argument defines if the way of how to update the joint. A joint connects two bodies. If the first one has moved and you want the second body to follow it use a value of 0. If it is the other way roudn use 1.
So a value of 0 is the most common case and that's also what you want to use.

Third argument is the node to b eused for the update, but I guess the linked function makes it a bit clearer anyway.


So, the tricky part for you is to find all joints that have been created by the dynamicMountAttacher script and update them only when it is needed.

just an incomplete hint:
for _,object in pairs(self.dynamicMountedObjects) do
print(" dynamically mounted object: "..tostring(object).." has jointIndex: "..tostring(object.dynamicMountJointIndex));
end

Cheers
Emil




Note: Log in to post. Create a new account here.