robit_studios's Forum Posts

  • Danijerry

    You are my hero. This worked like a charm. And I understand your method completely. I've implemented it in my game and it's working great. Thank you so much.

    Zetar

    Thank you for your help too. I love this forum!

  • Zetar

    Your method makes a lot of sense to me but I think there's a problem.

    <font size="2">System Compare Distance (Self.x,Self.y,ShipSprite.x, ShipSprite.y)<300</font>

    That line gives me an error saying you cannot refer to "self" in a system expression.

    The other problem is in line:

    <font size="2"> ->Set variable Self.AttackUID = ShipSprite.UID</font>

    I don't know how to set Self.Variable. I only know how to set a variable value for a specifically named sprite.

    I put together a capx that has a simple setup similar to what I have in my game. There is one ship sprite that can be 1 of 3 factions. When its in mode 0 it moves around randomly and when it's in mode 1 is moves towards the ship who's UID is stored in it's target variable. The ship is also in a family group called "enemy_ship". I'm using that family as a way to make the ship sprite differentiate itself from it's target. If you look at the code, hopefully you'll understand what I mean.

    http://dl.dropbox.com/u/28484936/target_ship.capx

    Danijerry Your method using another sprite sounds interesting as well, but my first attempt at it failed. If you have any other suggestion, or could take a look at my capx I'd appreciate it.

  • Here's a problem that I'm having trouble even beginning to implement.

    I use 1 sprite for all the enemy ships in my game. That 1 sprite has a variable called "faction" which can be 1-3. Depending on which faction it belongs to it'll change it's color and weapons, etc. If two enemy ships of different factions get close to each other I want them to target each other (in my case that requires a variable "target" to be set to the other ship's UID).

    I'm having trouble testing whether two objects, that are the same sprite- but are from different factions, are within a certain distance of each other. And if they are, changing each of their "target" variable to the other one's UID. This would be fairly simple if the two ships were completely different sprites, but there must be a fairly easy way to do it as I have it set up now.

    It kind of hurts my brain to think of how to make this work and I hope I've explained myself properly.

    Basically I'm trying to find a way to isolate 2 identical sprites that have different "faction" variables, compare their distance and if close enough set another variable, "target" to be the other sprites UID. Keep in mind that there may be as many as 50 of these sprites (of various factions) in the playfield at any time.

    Thanks.

  • Woops. I linked to the wrong capx file. This is the correct one: http://dl.dropbox.com/u/28484936/ship_shooter_animation_bug.capx

  • I found a bug in release R82 which makes my game unplayable. It appears that when a physics object has more than 1 frame of animation the physics completely breaks down. Here's a capx that shows the problem. You can press "T" to toggle the sprite between a 1 frame animation and a animation with more than 1 frame. Try moving the ship forward and then toggling on the animation to really see the problem.

    http://dl.dropbox.com/u/28484936/ship_shooter_animation_bug.capx

    Here are my specs:

    Windows Vista Home SP2

    64-bit

    GEForce GTX 560

    Chrome 17.0.963.79

    <font size="1">Edit: Corrected link to capx file.</font>

  • Jailson Did you ever have any luck with this? I'm also trying to destroy a distance joint at run-time.

  • Yann & R0J0hound

    Thank you both for your help. I've got my missile working just the way I want it to. I'm glad to hear part of my problem is a bug because I was beginning to go crazy trying to figure out what was wrong. Hope it'll be fixed soon.

  • R0J0hound

    I tried that and now I am getting the proper movement for the missile. But it causes a new problem. The missile is facing the direction that it's actually going, but I want it to always point away from the front of the ship, even though it's "global" movement may not be in that direction. I updated Yann's example and it shows pretty clearly what the issue is.

    http://dl.dropbox.com/u/28484936/ship_shooter.capx

  • Yann,

    Thank you so much for the help. Unfortunately it's still not behaving exactly the way I need it to. This only seems to work if the ship's angle is the same angle as it's velocity (in other words it's facing it's current direction of movement). But if the ship is facing a direction that is different than it's angle of movement the projectile doesn't behave properly.

    Imagine if you were driving a car in space (or a vacuum with no resistance) and you throw a tennis ball out of the side window. The tennis ball should move away from the car (at a 90 degree angle) but it also has the forward momentum of the car and no wind resistance. So while the ball is moving away from the side of the car it will also be moving in the same direction as the car. From the observer in the car it would look the same as if the car was stationary and he threw the tennis ball.

    That's the effect I want when the ship is moving in one direction, rotates his ship (but not changing his angle of movement) and fires a shot. The shot should move relative to velocity of the ship and away from whatever angle the ship is currently facing.

    Thanks again. Hope this helps explain what I'm looking for.

  • I'm having trouble working out the math for my 2d asteroids-style shooter. In particular when the player is firing a projectile from an angle different than their current angle of movement. This image will hopefully describe the issue clearly:

    <img src="https://lh6.googleusercontent.com/-Qqh-EwBXasU/T1vldGGu_HI/AAAAAAAAAec/yJ3AZ-RNcik/s720/angle_bullet_question.png" border="0" />

    The actual ship is using Physics for it's movement.

    The player's speed is determined using this formula:

    sqrt(player_ship.Physics.VelocityX ^ 2 + player_ship.Physics.VelocityY ^ 2)

  • Thank you for the help, everyone. This was very informative.

    Yann, I ultimately found your execution to be the most useful for my situation. Thank you so much for the time you put into that example project. The visual element really helped me to understand what was going on.

    My game is coming along very nicely, so far, thanks to all the helpful people on this forum. I love you all!

  • I made a little example capx that shows what I'm trying to accomplish.

    http://dl.dropbox.com/u/28484936/pick_closest_problem.capx

    The ship that is controlled by the mouse is a part of a family called "Family Enemy Ships". There are two types of ships in this family. I want to be able to set an instance variable for the mouse-controlled ship to which ever object from that family that it is closest to. Currently it always picks itself as being the closest.

    Hope this helps explain my situation.

    Thanks, Kyatric!

  • I have an enemy ship sprite and I want to set one of it's instance variables to be the closest enemy ship that isn't itself. If I use the "Pick Nearest to" condition it will always pick itself, which doesn't help me.

    Any ideas on the easiest way to do this?

    Thanks.

  • Ashley,

    Brilliant! You solved my issue! I had to adjust it a little bit to account for the rotation of the "Player".

    So, my code looks like this:

    Is 30 degrees within Player.Angle-angle(Player.X, Player.Y, Target.X, Target.Y)

    and

    Is clockwise of Player.Angle-angle(Player.X, Player.Y, Target.X, Target.Y)

    Once I did that, it works like a charm. I updated my capx that I was using as an example. I'll leave it up as it will hopefully help someone else who has this same question.

    http://dl.dropbox.com/u/28484936/within_angle_test.capx

    Thanks again!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I didn't think those conditions could test a sprite's position within another sprite's angle.

    Don't they just compare the angles between two sprites?

    If there's a way to use them to know another object's position, I'm missing how to do it.

    Edit: Ah, I see my wording was a little misleading in my last post. I edited it to be a little clearer.