randomly's Recent Forum Activity

  • The background:

    In my current little project, I created a rocket (with the bullet behaviour) and a moving target.

    The rocket (obviously) has a specific, constant speed and the target is moving horizontally by using the 'Sine' behaviour.

    I now want to implement an option to make the rocket act as if it was a homing missile.

    This means that I want the rocket to head towards the targets direction, considering the own speed and angle and the targets movement direction and speed (though it isn't constant).

    I don't want a ridiculously long function, but it should not just be

    Set Self.Angle towards position Target.X, Target.Y[/code:1qslgdh9]
    
    [b]My thoughts:[/b]
    Initially, I used exactly that action which (of course) didn't have a high success rate, since the target is moving.
    
    So I considered giving the rocket the 'Turret' behaviour, setting it to 'Predicted aim' and control the angle by that.
    That worked quite well.
    I can even control the rockets accuracy with the turret's turning speed and the range.
    
    My question is now whether there is any way to control the rocket which works even better than that?
    I just started using C2 (two weeks ago) and I know that this is quite ambitious, but I wanna see where I can get and I know that this awesome community is always up for a challenge. ;)
    
    Here is an image of my current function:
    http://i.imgur.com/gHmy7Gd.png (sorry can't make it clickable yet)
    
    Have a nice day, thanks for any reply! :)
  • Here's an example I created on how you could do it.

    The version is very buggy but I think it demonstrates well how you could do it.

    Download:

    dropbox.com/s/ynca7s7w74vkf22/JumpNuts.capx

  • Yes, that is possible.

    Actually, that would be very easy once you start to understand C2.

    You don't need much knowledge of C2 for a trivia game, just start learning the basic mechanics of it and you'll be good to go!

    Here's a tutorial to begin with: scirra.com/tutorials/37/beginners-guide-to-construct-2

    Have fun! :)

  • tunepunk mrinmoysd

    Yeah that's the way, I'd do it too.

    When you click, your player is given a speed by an action and set loose from the ball, making him fly towards the next ball in a physically correct way (caused by the bullet behaviour).

    As soon as he touches the next ball, the coordinates are being saved. The angle of the ball would then have to be switched towards the player (to be able to calculate his position on the ball).

    his position can then be calculated like so:

    x position: ball.x (make hit-spot -> center) + ball.radius*(cos(ball.angle)) | you'll have to calculate the radius from the size of the sprite.

    y position would be similar, just with sinus.

    I hope we could help you, if you need any more help, just write us.

  • Hi,

    could you provide us with some more information?

    Maybe a .capx and a detailed explanation of your problem & project and what you mean by "node"?

    Thanks.

  • So, if I understand you correctly, you don't need to change LevelCtr value when the level you choose is lower than the maximum level you reached right?

    I would say that you need to get the LevelCtr from LocalStorage as soon as you start the game. That's probably the one and only time in your game where you should get the value from the LocalStorage, since the global variable "LevelCtr" isn't dependant on the LocalStorage Key.

    You just need to check the LocalStorage Key when you start the game.

    At the beginning of every level, you should check whether the current level's number is higher than the current LevelCtr and if that is the case, save the level's number as the LocalStorage "LevelCtr_Key".

    Lastly, when the user quits the game, the current "LevelCtr" should be saved to the LocalStorage, in case, the "LevelCtr" variable has increased since the last change of the "LevelCtr_Key".

    This should work, in theory.

    Your images look like you don't have many events, so I'd be happy if you could provide me with a .capx so that I can refer to the event sheet context too. Thanks. :)

  • Hi, if you'd give us a link of that game you are referring to, that's be very helpful.

    I can't find it on the web.

    Or if you would describe the movement needed.

  • So, what exactly does the LevelCtr (global) value store? Does it store the amount of levels you have already played? Or the number of the level from which you quit the game last time?

    I can see that you use the LocalStorage object correctly, I think the problem you are having is caused by the use of the variable. If you could tell us more about your LevelCtr variable, me might be able to solve your problem. :)

  • Thanks so much for taking the time and creating this (beautifully named) project for me.

    My first ever time I ask for help in this forum and I immediately get such a friendly response.

    This community is awesome.

    I read through the .capx you provided. I fixed my project now by changing the Angle check to the one that you proposed (Pick shell where int(Shell.Bullet.AngleOfMotion) > 0) which also allowed me to remove the now unnessecary UID instance variable.

    I also removed the CheckShellMovement function which isn't needed now anymore because I can just pick the needed shells.

    Thanks so much for taking the time to take care of my issue. If you have a problem at some point (maybe with particles), I will do my best do help you too.

    Also, thanks to DankP3 for proposing the global variable to be changed to an instance variable. Would probably have fixed my problem too.

    Now I have a compact and working new version of my project, thanks everyone.

    (Btw, 99Instances2Go, you said there are too many "If->Then" in my project? Could you tell me how I can improve this? Not in this thread, but via PM maybe? I don't have gained the power of writing PM's yet though. Maybe you could send me one quickly? Just if you have the time of course.)

  • Thanks for your response and thanks for clarifying what I did wrong.

    Sorry for the errors I made.

    I removed everything distracting from the project and deleted all used plugins from the project.

    I then exported the capx and included the new link in the edited post.

    The last time when the link redirected to a backup file, that was a Dropbox issue since C2 automatically creates backups, even for .capx.

    Thanks again for taking the time to help me solve my problem.

    (By the way, English is not my first language as you might notice)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hey everyone,

    first of all, let me tell you that this is just a hobby project of mine. I continue to develop it in my free-time.

    I also started using C2 like two week ago, so my skills aren't that advanced and there is probably much much more to improve in my project than just that what my question concerns.

    But I don't expect you to correct all my nooby mistakes, should you feel obliged to do so though, I'd appreciate a PM.

    Let's get to my main concern, shall we.

    My project is a kind of weapon sandbox (.capx download further down), also serving as a playground for new addons and to advance my knowledge of C2.

    The feature which is the most important for my issue is the following:

    You can shoot grenades (bullet behaviour) which explode on colliding with the ground. You have the option to enable "Shell mortar". This childishly named option causes the grenade to spawn two small grenades to spawn when the initial grenade is at the height maximum of its flying arc.

    For checking whether the grenade is at its maximum, I created a function which compares the grenades current angle with its angle from the previous tick (stored in an instance variable). If the current angle is lower than the last known, the function returns a 1 and saves the grenades' UID in a global variable.

    This UID is then used to indentify the grenade which should spawn the two smaller ones.

    So far, so good. This works fine.

    As long as you don't fire multiple shells in a short time. Because when you do that, just some grenades trigger and spawn small grenades.

    This is my actual problem.

    I don't know what causes this issue, maybe the UID being stored in a global variable, but I see no other way of doing it.

    Anybody who is willing to read through some of my events can PM me or just reply here.

    Any help is appreciated.

    I now removed everything distracting from the project and removed any plugins used. I hope this won't cause any errors anymore for you.

    Since this is my first post, I apologize for anything being unclear, I will provide any info needed.

    Thanks so much in advance!

    Download .capx: (important sections are bookmarked)

    dropbox.com/s/3dpfzphgqnx6efv/GrenadeLauncherForumVersion.capx

    (Some additional info:

    I also have an option called bounce which causes a grenade to bounce once after colliding with the floor and exploding after the second impact.

    I noticed that if I enable both bounce and mortar rain options, some of the grenades which don't trigger, do trigger after having bounced and reaching their maximum height in the second arc.)

    [EDIT: As I said, I'm still learning, so there is most likely much to improve. Just try to ignore this. :)]

randomly's avatar

randomly

Member since 26 Sep, 2016

Twitter
randomly has 1 followers

Trophy Case

  • 8-Year Club
  • Email Verified

Progress

9/44
How to earn trophies