How do I make my character to rotate around another object?

0 favourites
  • 7 posts
From the Asset Store
Simple resize and rotate events for any sprite, quick and easy event sheet that you can use for your own projects.
  • Greetings everyone,

    Here is my project: 1drv.ms/u/s!Av6DKHz8GbeYkQoh1RVjS9nTc0CV

    As the title suggest, I'm trying to make my character rotate around a specific object. The object in question is a "hook" that can be thrown by the player using RB on a controller. When the hook hits a wall or a ceiling, the character is expected to rotate around the hook.

    The idea I have is something that has already been done in the past, the game "speedrunners". Here's a footage of the game and the behavior I'm looking for: youtube.com/watch

    I'm trying to reproduce that behavior in construct 3. I already have the hook to stay in place when it hits a ceiling, but now I'm in a dead-end for the rotation part. I checked over similar problems on the forum but couldn't find anything conclusive. Here's what I have so far: youtube.com/watch

    Thank you in advance.

    Tagged:

  • Making a grappling hook in C3 may be a tricky task. There are a couple of official templates:

    https://editor.construct.net/#open=gold-mining
    https://editor.construct.net/#open=hook-shot
    

    You can also try searching the tutorials section, for example:

    construct.net/en/tutorials/grappling-hook-example-capx-659

  • Thank you for replying dop2000,

    I think the word "hook" was kind of misleading towards what I'm really looking to. I don't want anything to go from one point to another like the offered templates, I want the character to rotate around it.

  • You can make the rope invisible, but I guess the principle will be the same.

    There are several ways to do this. One time I made a realistic grappling hook mechanics with Physics behavior - when the hook is attached, I disabled Platform and enabled Physics, creating a revolution joint and applying impulse. But I wouldn't recommend this, as Physics is not compatible with other behaviors like Solid etc.

    You can also use Orbit behavior to rotate the player around the hook point.

    Or use Sine/Rotate behavior on the rope and pin the player to it (disabling Platform temporarily).

  • Here’s one way to do it. Basically when creating the X you save the distance between the player and the X to a variable. Then while swinging you move the player so it’s at that same distance from the x. Also we cancel the perpendicular velocity of the player.

    The result should be swinging while keeping momentum.

    var d=0
    var a=0
    var vperp=0
    
    on x created
    -- set d to distance(player.x, player.y, x.x, x.y)
    
    compare: x.count >0
    -- set a to angle(player.x, player.y, x.x, x.y)
    -- player: move d-distance(player.x, player.y, x.x, x.y) pixeks at angle a
    -- set vperp to cos(a)*player.velocityX+sin(a)*player.velocityY
    -- player: set velocity to (self.velocityX-cos(a)*vrel, self.velocityY-sin(a)*vrel)
    
  • Thank you both both of your replies dop2000 and R0J0hound. I was able to get a very similar result with both of the orbit behavior and the less intuitive method from hound. By the way Hound I think you mentioned the variable vrel but I assume you meant vperp.

    On both cases I definitely get the orbit around the tip, what I was looking for. However now I'm struggling with the release of the orbit around a point, as it doesn't follow the swing's momentum (when I release the orbit) and always go straight down. It seems that if I disable the platform behavior, then the character follows the swing's momentum, but then I can't control the character anymore. And whenever I enable the platform behavior back again, the character's momentum is stopped dead in it's track. I will try a workaround of all this, but both orbit and hound's method worked for what I initially was looking for. Thank you guys.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I'm struggling with the release of the orbit around a point, as it doesn't follow the swing's momentum

    Check out this demo:

    dropbox.com/s/619rfvzuuhotepo/GrapplingHook_Velocity.c3p

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)