[SOLVED] Expression to return value of force applied to object ever existed?

Does my memory is wrong and it does not exist or i am looking for wrong thing?

Basically i BELIEVE i saw expression to return whatever force was applied to object
Imagine i have fan and i rotate it with some force
Now i could apply same force to some other object
BUT instead i would use Fan.ForceApplied() on my other object

But i can’t find it i think i am confusing it with something
But for sure something like this exist but maybe for something else
Maybe i confuse it with some platformer behavior expression
Like checking vertical speed or something

Well whatever
If i am wrong then i am looking for a way to apply exactly same force to object B that i am applying to object A

Yeah most simple solution would to do it via events when i apply some force to object A also apply it to object B
But my goal is to somehow read/return whatever force was applied to object A and apply it to object B

It depends on the way it’s being moved.

Default force

Physics has

There are probably other expressions.

Yeah it works if i would want to move something with forces
But i want to rotate something with forces that’s why i gave fan example
I have this ship with cannon on the back
(Not my game not my art not my idea)
And i need it to rotate with same force as ship does
Problem is it rotates toward some position and i can’t have cannon rotate toward same position because it will always be facing same direction as ship
Where what i want to achieve is imagine you have piece of paper
You put on it pen and now you rotate ONLY that piece of paper
And i want to mimic behavior how pen will act that it will spin with that piece of paper like its jointed to it

While i still need to have ability to move that cannon on its own
So my only solution is to always apply same rotation force to cannon as ship is getting and then i can in separate event add on top of that however i wish to rotate cannon on its own

If i use 2 keys to add/subtract to/from angle of ship and same to cannon it works perfectly
Problem is in game ship will rotate toward where you click so that is not an option for me

For clarity, are you using the basic forces or are you using physics?

Physics has joints and if not physics then maybe you can add a point on the ship and position the gun on that point and then rotate it. Unless, I’m missing something.

A screenshot of the events might help.

It is already mounted on a point
Maybe its not so obvious but cannon is here
Pointed to the right since that is default angle position
As you see i did rotate ship yet cannon did not rotate

My events won’t tell you much since they are what i said
Ship will rotate toward position where you click
For now i am manually rotating with Z and X adding or subtracting from ship angle

Canon is rotated toward mouse cursor with either +50 or -50 depending on which side of ship cursor is
Ok lets call it gun since even in events he named it gun

And it works perfectly when ship is not rotating
Because guy who is making this game wish to have dead zone from gun to center of ship about 45°
So gun cannot turn trough ship

Basically gun can rotate left or right yet it cannot go trough red lines
When it reaches red line it stops
If gun is on the left side of ship and needs to get to right side of ship it will go counter-clokcwise if gun is on right side of ship it will go clockwise
I did it it works perfectly fine
But because it stops at are between red lines
And it is not turning WITH the ship
It is possible for it to go trough that dead zone
That is why i need it to get constantly same force applied to its rotation that ship is getting

This is how i rotate ship RIGHT NOW which will be different in the end game like most likely it will rotate to where player clicked
I am not sure what author have in mind

And as you see i have same actions in sub events for gun
And it does work perfectly and that’s how i know i need same force applied to ship angle/rotation be applied to gun
Btw on ship there will be 4 guns in total in different places

And this is how i rotate gun
Depending on which side of ship cursor is

Which is just as i said either +50 or -50

I did try to go with adding ship angle to that +50 / -50 yet it spins way too fast

And how do i know that?
Because i tested method with ship angle vs without ship angle but rotating gun with ship by enabling these sub events

You seem to have it pretty well in hand.

My strategy might be to set the gun based on the angle of the ship - 180 and then add an +/- offset between the limits.

I would have to experiment. I’m not sure if my approach would work any better than what you have.

My problem is not with how to limit gun
My problem is with how to provide same rotation to gun as ship is getting

And i already explained in previous message that when i try to set gun angle to ship angle +/- some force results in gun spinning too fast

This is version where by holding Z or X you add/subtract 1 to/from ship and gun angle
While in separate event gun is rotating toward mouse cursor
So this

So it is exactly what i need
But i won’t know when what force is rotating ship since i can’t find expression for it

And this is rotating on ship with Z X
But each time gun moves it goes to ship angle + / - some number
So this

Not to mention this method bugs out depending on angle of ship

Easiest test for both methods is to leave cursor in 1 place and just hold either Z or X

So all i need is to read with what force ship is rotating
So i can use it on other object which is gun in this case

I’m not going to be able to help here. If there’s not the right expression then maybe you need to calculate it yourself. I figured I could calculate things based on their previous values and current and maybe include TimeDelta but I might be way off and I just don’t have the knowledge of the whole issue. I wish you luck.

1 Like

I mean i was 100% sure there is expression for it
Anyway i know how to check which way ship is turning
Pretty much same way you check does mouse moved
And i even think you taught me how to do it
Anyway force of rotation will always be the same only direction will be different so either positive or negative

But i was hoping there is some easier way
Well whatever

Thx for trying

1 Like

OK turns out checking if ship angle changed and then applying same force ship would get by rotating toward something to gun actually works perfectly fine

1 Like