Stop slow parent when aiming down sights?

…and done entirely in logic too.
Holy crap, that’s a lot of brick :spin:

I had no idea you could insert “True/False” under ‘Value’ in a Property brick, that’s neat!

Definitely gonna look more into that file, it’s pretty interesting

.035 logic usage :smiley:

The snippets are just sample code. I do not recommend to use it as it expected a certain setup that is not mentioned anywhere.

Here is a snippet just out of my head.

slowparent.py [updated 1.1]:


import bge

PstoredTimeOffset= "_storedTimeOffset"

def disable():
    if not areAllSensorsPositive():
        return

    storeTimeOffset()
    owner = bge.logic.getCurrentController().owner
    owner.timeOffset = 0.0

def enable():
    if not areAllSensorsPositive():
        return
    
    storeTimeOffset()
    owner = bge.logic.getCurrentController().owner
    owner.timeOffset = owner.get(PstoredTimeOffset, 0.0)

def storeTimeOffset():
    owner = bge.logic.getCurrentController().owner
    if not PstoredTimeOffset in owner:
        owner[PstoredTimeOffset] = owner.timeOffset
    
def areAllSensorsPositive():
    for sensor in bge.logic.getCurrentController().sensors:
        if not sensor.positive:
            return False
    return True

How to use:
The “slow-child” must be slow-parented to another object (do not remove this parenting during game!)
At the “slow-child” needs this logic:

A) sensor(s) the evaluate when to enable slowparent -> Python Module: slowparent.disable
D) sensor(s) the evaluate when to disable slowparent -> Python Module: slowparent.enable

you can for example use a mouse button sensor, or a message sensor, or whatever.

.035 logic usage

Impressive!

What would be considered the Slow Child in my scene?
I have the brick setup (I think) but first I want to be sure its attached to the correct object.

1)No properties required?
2)The modules brick has to be named slowparent.enable?

If you refer to my solution. No, you switch the Python controller to Module mode and enter “slowparent.enable” into the module field. Be aware slowparent refers to the filename slowparent.py (the name of the text block you paste the above code into). So you need a little bit of typing (Hint: or you copy and paste it :D).

You can use a property if you want. In that case you can use two PropertySensors (one checking the when to enable, and one when to disable). But you do not need to. As said you can use other sensors too. It is up to you what you like.

The performance impact if very low and only during the events (e.g. when you click the button, not while you hold the button). Avoid True/False Level Triggering at the sensors. You do not need it and it would be inefficient.

Yeah, I named the script “slowparent.py” and for the module used ‘slowparent.enable.’
Figured I’d use RMB sensors, seeing as that’s what controls the zoom… though I feel I’m way off. Dangit


Again, is it supposed to be attached to the object that has “slow parent” checked off?

and now My version :smiley:

Now with Kung-Fu Zoom action

Attachments

LogicZoomAndGunLag (B).blend (484 KB)

It must be the child. And slow parent needs to be enabled. This is because it is not possible to enable slow-parent in game. But you can change the offset (what the code does). Be aware if you un-check slow parent (default) the above code will no have any visible effect.

The above screen shot looks as it should be (even without seeing the sensor configuration). Mouse2 should be inverted (when listening to the same button) or listening to a different button.

@RandomPickle97 It worked for me! I tried it on a simple cylinder, but it worked. Mouse2 was inverted just as Monster said, so maybe try that.

@Ezio: If you still have the file, can you share it?
Also, I tried it inverted but to no avail. I must have screwed up somewhere…

You mean the script or my .blend?

EDIT: I added my .blend. My gun is rather lame. :stuck_out_tongue:
[ATTACH]317649[/ATTACH]

Walk around. Hold RMB and slow parent stops. Let it go and slow parent continues.

The blend!

Edited my post to contain the .blend! Reattaching anyway lol!

[ATTACH]317650[/ATTACH]

Just in case you didn’t get it.

The setup was right, and it was set to the correct object…
not sure what the problem was, but I copied and pasted the script from your file to mine, and re-wrote “slowparent.py”…

WORKS NOW!
I must have had the mouse over the Text Editor and hit a HotKey…

Thank you all so much! :smiley:

@Monster: How do you mark a thread as solved? Didn’t it used to be in “Thread Tools”?

Edit post>Go advanced>Prefix=SOLVED.

Completely forgot about that… used to be so simple!
Thanks!