Blue Emerald Posted October 7, 2008 Report Share Posted October 7, 2008 I've been working with the Sonic Worlds engine for a while, and I've got the Crabmeat Badnik shooting the bullets, but they're being launched diagonally outward. I want them to launch in an arc like in the Genesis games, but I can't figure out how. I tried setting the Y position as a parabola formula, but that didn't work; it just made the bullet disappear. Does anyone here know how to get the bullets to launch in an arc shape? I've got some other Badniks planned for my game that will launch projectiles in arcs, as well, so this is going to help me a lot. Link to comment Share on other sites More sharing options...
LarkSS Posted October 7, 2008 Report Share Posted October 7, 2008 Just apply simple gravity. When the bullets shoots, set both to have a negative Y speed and inverse X speeds. Then have the Y speed ( which should be stored in an alterable value within the bullet object itself ) always increase by a certain amount ( I like 0.314 ). To position the bullet, have two alterable values in charge of the X and Y positions of the bullet. When the bullet is created, set these values to its current position. Then, always add the X and Y speeds to the appropriate position values. MAKE SURE to do this by using the 'set value' perimeter; add or subtract remove the decimal data of the value. Finally, always set the position of the bullet to its X and Y position values. Just make sure that when the bullets are shot that you set the speed values accordingly and set up the position values as soon as they're created. Should work fine if you do it correctly. Link to comment Share on other sites More sharing options...
Appo Posted October 7, 2008 Report Share Posted October 7, 2008 Hey, i made an example of this last night but i se LarkSS beat me to it, it's not much different to what he's saying but if u would still like the example file i'd be happy to post it Link to comment Share on other sites More sharing options...
Blue Emerald Posted October 8, 2008 Author Report Share Posted October 8, 2008 I'm not sure how to make the inverse X speed, so, Appo, if you could post the example, that would really help me understand. Thanks. Link to comment Share on other sites More sharing options...
Appo Posted October 8, 2008 Report Share Posted October 8, 2008 no prob Crabmeat shoot.mfa 1 Link to comment Share on other sites More sharing options...
LarkSS Posted October 9, 2008 Report Share Posted October 9, 2008 I'm not sure how to make the inverse X speed, so, Appo, if you could post the example, that would really help me understand. Thanks. Though Appo already posted a tutorial ( which is worth more than a thousand words imo ), inverse X speed isn't really any matter of difficulty. Simply put, if a positive X speed value moves to the right, then a negative X speed value will go to the left. So to inverse the X speed, simply set a negative value. Doesn't get much easier than that. =P 1 Link to comment Share on other sites More sharing options...
Sockman Posted October 11, 2008 Report Share Posted October 11, 2008 Make the bullet Ball Movement and just add (or subtract, depending on the direction) a degree of the angle of the bullets movement until its moving downwards. 1 Link to comment Share on other sites More sharing options...
Blue Emerald Posted October 12, 2008 Author Report Share Posted October 12, 2008 Appo, I used your example and placed it into Sonic Worlds, but the bullet's movement is different. Instead of going in an arc, it just shoots down. However, it does shoot at the same speed as it did in your example. I'm thinking that your alterable values might be different from Sonic Worlds' alterable values. Did you use different alterable values in your example? Well, for now, I'll try your idea next, Sockman. EDIT: Sockman, you are a genius. It works! It actually works! Of course, I couldn't have got the whole thing to work without LarkSS or Appo, either. I'm not kidding; both of your ideas helped with this, especially Appo's example. For that, I'm giving all three of you rep points. Thanks so much for the help! Link to comment Share on other sites More sharing options...
DimensionWarped Posted October 12, 2008 Report Share Posted October 12, 2008 Not physically accurate though. If it weren't MMF, I'd also assume that running all of the code for the bouncy ball object would be a harder processor hit overall than just using a parabolic function. Link to comment Share on other sites More sharing options...
Blue Emerald Posted October 12, 2008 Author Report Share Posted October 12, 2008 Well, the ball effect is the closest I've come to getting the arc. The example only made it shoot downward, and I don't know how to make it shoot up and outward at the same time it shoots down. The example worked on its own program, but when placed in the Worlds engine, it was different. I think it has something to do with the alterable values, but I don't know if those values can be changed, or if they're all the same, but with different functions. Link to comment Share on other sites More sharing options...
Appo Posted October 12, 2008 Report Share Posted October 12, 2008 Actualy that did happen when i first mdae it but i fixed it, however i didn't try it in the worlds engine which i should of done really, but if you would like i'll have a paly with it in the worlds engine unless your happy with Sockmans idea EDIT: Hmm ok so i played around with it a bit and it works, but it will only create bullets from the first enemy you encounter i can't seem to figure out what is going on because it works in a blank application, anyways i'll upload the file and hopfully someone can point out what went wrong, just copy the two bullets in the level editor into the worlds engine then in the events just copy the parts out of the firing bullets group Crabmeat shoot.mfa Link to comment Share on other sites More sharing options...
Blue Emerald Posted October 12, 2008 Author Report Share Posted October 12, 2008 Well, I just tried it, and it works beautifully; I didn't have any problem with the other Badniks shooting bullets, so maybe there's a condition missing from your engine or there's an extra condition that's causing it to happen. My first theory was that the "only one action when event loops" condition was causing it, as I didn't use the first one in your example, and my engine works fine; but when I tested my theory on your example file, the Crabmeat started shooting lasers, Gradius-style! So yes, I have confirmed that the reason the bullets work differently on the two files is because the alterable values between the two are translated differently. Thank you for checking that, Appo. Link to comment Share on other sites More sharing options...
Appo Posted October 12, 2008 Report Share Posted October 12, 2008 np, would it be possible for you to posst a screen shot of the event you put it because if i take the loop only on event out it works on all the crabs but i get the 'Gradius-style' effect but when i put it in it works properly but onl on the first crab unless i destoy it....which is weird :S Link to comment Share on other sites More sharing options...
Blue Emerald Posted October 12, 2008 Author Report Share Posted October 12, 2008 Sure thing. Here it is. Ignore 1212 and 1214, and as for the "play Aquatic_Shield," that was only a test to see if the event worked in the engine. The Crabmeat bullet on the left is on the top half of each of the events, and the one on the right is on the bottom half. Link to comment Share on other sites More sharing options...
Appo Posted October 12, 2008 Report Share Posted October 12, 2008 ah thank you so much i just had the create event in the wrong place, thanks for that Link to comment Share on other sites More sharing options...
Recommended Posts