hrisnz's Forum Posts

  • lennaert thanks again!

    I always used add X to Y unless Y is < 200 for example clamp() will make my life easier now.

    And thanks for the 60 * dt = 1 sec

    makes even more sense now

  • oh lennaert and I implemented your 6*dt instead of the 0.1 in the position lerp. That was a really nice tip Thanks!

  • Thanks a lot 99Instances2Go !

    Your feedback helped me a lot with understanding "Trigger once while true" events and your solution seems really elegant <img src="{SMILIES_PATH}/icon_razz.gif" alt=":P" title="Razz">

    I implemented changes based on your suggestion and fixed the bug. Your way worked perfect until the point where the players position on the rotating layer (CanvasX, CanvasY) got into negative values. It started to confuse the set angle bullet behaviour and ignored the destroy on overlapping.

    The fix: It seamed like a problem that the collectable object and the player object where on different layers for the lerp positioning to work (even though translating the position by LayerToCanvas etc). So I added a new Object on the same layer as the collectables (called "PlayersDestroyer") set it to CanvasX, CanvasY (the Players "true" location) and made the collectables die when overlapping this object. Works supa smoothly <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

    Here is the result:

    https://www.dropbox.com/s/e17ienhb6h46u ... 8.png?dl=1

    lennaert

    Thanks for tip with the "clamp" function! I tried it out a little bit but since the current way works perfect It seems like I don't need it. But "clamp" looks really helpful. Now I can use it in the future <img src="{SMILIES_PATH}/icon_e_wink.gif" alt=";)" title="Wink">

    What was your "most creative way" of using clamp() so far?

    Have a great day,

    Chris

  • thanks for your reply lennaert

    This is what I found in the manual:

    clamp(x, lower, upper)

    Return lower if x is less than lower, upper if x is greater than upper, else return x.

    But I still don't understand how it could look or how I could apply it to my:

    X = lerp(Self.X,CanvasX,0.1)

    Y = lerp(Self.Y,CanvasY,0.1)

    Could you give a plain example please?

    Do I get it right that the clamp function sort of gives the X (or Y) value sort of a frame between a min and max value?

    Thanks,

    Chris

  • SOLVED:

    It actually worked:

    http://www.hinz-art.com/testserver/Cassini_2/index.html

    https://www.dropbox.com/s/jscin0tpb5tg2 ... d.c3p?dl=1

    Project file is structured, labeled and commented.

    I hope this will help anyone who is trying to find a way to get the "true angle" of objects cross different layers (with different rotations)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hello Scirra community,

    I'm working on an endless runner with main focus on its mechanics feel, camera movement and story.

    You can play the WIP here: http://www.hinz-art.com/testserver/Cassini_2/index.html

    I have some trouble with the "Collecting System" (fly close to yellow circles and press "D"), sometimes the position lerp function does weird things. Especially when the LayerToCanvas coordinates (that tell the collectables the "true" position of the player on Canvas ("CanvasX" and "CanvasY") get negative.

    Anybody got any feedback on that? (Or the overall early process)

    Would be much appreciated <img src="{SMILIES_PATH}/icon_e_wink.gif" alt=";)" title="Wink">

    My project file is structured, labeled and commented. If you want to have a look:

    https://www.dropbox.com/s/jscin0tpb5tg2 ... d.c3p?dl=1

    Have a great day!

    Chris

  • Here we go <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

    https://www.dropbox.com/s/ruzmghista1pn ... e.c3p?dl=1

    This is the solution mentioned in my post above. It works. But it has a tiny delay <img src="{SMILIES_PATH}/icon_e_sad.gif" alt=":(" title="Sad">

    Any optimisation tipps?

    Explanation:

    • Left, right arrow rotates the player
    • Up and back arrow accelerates
    • Press E and R to rotate the level ... and see how the custom shadow repositions itself according to the levels rotation and the new true angle (rotation will be done automatically later) - E is a lot faster for testing purposes

    My goal is:

    • To set the "Custom Shadow" to the players true rotation (level gets rotated, player doesn't, the shadow should still rotate) ...
    • ... so I can place the shadow on a different layer since I want to set its blend mode to "source in" and place all "ground" elements on the same layer to have the shadow only be visible on the ground objects but not the rest.
  • It might be a possibility to just make a "start screen"?

    Touching "Start" causes the mobile event to start and clicking it runs the desktop event.

    Hope this might help

  • Cmd + R is my best friend while testing in a new browser tab - or multiple.

  • EDIT:

    Ok, one night of thinking brought me to the following:

    It would be really useful to have an easier way in C3 to detect the true position of an object and its true angle (with true I mean on canvas, incase separate layers are rotated for example).

    Using the CanvasToLayer method works, but it only gives the "true" position of an object for one different layer. So if you need to translate multiple objects to multiple layers it can get quiet confusing.

    And there seems to be no direct way to detect an objects true angle (on canvas).

    Regarding the whole true angle issue, I figured it might be a possibility to "pin" an object (for example) behind or in front of the player object, detect the players position X,Y through CanvasToLayer and detect the pined objects position X,Y through CanvasToLayer and set a third objects width to X=PlayerX,Y and Y=PinedObjectX,Y and its angle to ..... mmh wait. But you get the point: the goal is to translate the true angle of the player object to a different layer by detecting two points "on" the player object, so a third object can mimic those two points, creating the true angle on a different layer.

    Does anybody know how I can set the "third object" so it uses the two CanvasToLayer coordinates to create the true angle of the PlayerObject?

    I'm thankful for any help

    Best,

    Chris

  • EDIT:

    Or is there a way to show/render/blend/view Sprites only on certain objects (on different layers) this would make creating custom shadows so easy!

  • Hello Scirra Community,

    is there a way to detect an objects real angle?

    Example:

    Layer 1 = Sprite 1

    Layer 2 = Sprite 2

    • Sprite 2 is set to Sprite 1 + offset (to mimic a shadow)
    • if Layer 2 gets rotated, Layer 1 naturally doesn't
    • therefore setting Sprite 2s angle to Sprite 1s wont work anymore.

    I came around this problem with positions using the fantastic function of LayerToCanvas and CanvasToLayer.

    Is there something similar or a workaround to detect the "true angle" in relation to the canvas?

    Thanks for any advice and help

    Best,

    Chris

  • 99Instances2Go

    LOOK AT THIS BEAUTY <img src="{SMILIES_PATH}/icon_e_biggrin.gif" alt=":D" title="Very Happy">:D:D:D:D

    https://www.dropbox.com/s/lz6ru0uhvcg93 ... 3.c3p?dl=1

    oh man, I must say it took me a couple of good hours of frustration. But finally I managed to understand and execute your advice.

    Anybody who wants to try it:

    • Press U to lerp the circle to the player
    • Restart Layout
    • Press R to rotate the "rotating layer"
    • Press U now AAAAND THE CIRCLE STILL lerps to the player <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">))))

    a bit odd how happy something like this makes me <img src="{SMILIES_PATH}/icon_e_biggrin.gif" alt=":D" title="Very Happy">

    Thanks again and again!

    #solved (lerping position of two objects on different layers when rotated)

  • EDIT!!!

    Aahhhhhhhhhh. I see: The third attempt is working. But if the "new sprites" spawn at the "old sprites" location (even if it is on the player's layer), they will still spawn at the old sprites "location" in the old coordinate system. And therefore work but start of at the wrong place (old sprites location)

    So your way should indeed work!

    To me it seemed the same. But now I see its not

    I will keep you updated

  • Good morning 99Instances2Go,

    I was experimenting last night and this morning and came to the following:

    • I didn't try your attempt yet (because actually I'm afraid it wont work). Let me explain:
    • What you said and your solution seems perfectly fine and will probably work for detecting the "real" coordinates over multiple layers with different parallax
    • But doesn't this mean it should work with object on the same layer (in the same coordinate system)
    • So to try if your "right" way will work I thought about this:

    1. attempt: On event - move collectable to same layer as the player + set position to perp(self,player,x)

    https://www.dropbox.com/s/lqse3r6v6210g ... 5.png?dl=1

    • But it seem (when rotated) to still stay in its "own" coordinate system. So i tried this:

    2. attempt: (You can skip this one actually since I changed this version in attempt Nr. 3)

    • Created a new object (which will be the collectable in its active state) /like a different coloured clone
    • Gave it an instance variable (0)
    • On (collecting) event: set instance variable to 1
    • If instance variable = 1 set "clone's" position to perp(self,player,X)

    + trigger once while true: Old collectable - Spawn - "clone" on "Player's" layer

    • destroy "old collectable"

    https://www.dropbox.com/s/5dxow7en6mfi8 ... 7.png?dl=1

    Also didn't work.

    3. attempt:

    • This is a modification of the 2. attempt
    • I found out, that my instance variable on the "cloned" collectable on the players layer didn't work <img src="{SMILIES_PATH}/icon_e_biggrin.gif" alt=":D" title="Very Happy">
    • So I tried the same approach with a global variable
    • Since then the new (cloned) collectables at least lerp to the player position successfully and don't bounce of the grab zone anymore
    • But they still start lerping from the "wrong/old sprite's layer coordinate"

    https://www.dropbox.com/s/lgrm657d372ag ... 8.png?dl=1

    Before trying your attempt I was just wondering if you think that it will do any difference if it already doesn't work even if the sprites are on the same layer. The point is: I don't understand why to objects can't be lerped to each other when on the same layer just because there is a rotating layer underneath. Confuses me <img src="{SMILIES_PATH}/icon_e_biggrin.gif" alt=":D" title="Very Happy">

    Thank you so much for all your help!

    New capx

    https://www.dropbox.com/s/4st58c0i4urcx ... 9.c3p?dl=1

    Have a great day,

    Chris