Making a ball curve in flight on rblx lua - lua

Ok im trying to find a way on roblox to script a ball that launches in the air using BodyVelocity but then instead of going streight down I want it to curve like do an arch then fall.

ROBLOX physics simulations are... curious, to say the least. If you want to move in a perfect arc, your best bet is to just set the CFrame of the object directly. In order to calculate that, you'll need some physics knowledge. I recommend reading up about parabolic motion and CFrames before giving this a shot.

Related

Using physics to move a object along a track/rail

I'm hoping to simulate the movement of a train along a fixed path. The path itself is representable by a CGPath.
So far, I've found SKPhysicsJointSliding, which seems close, but appears to only work along a fixed axis, and since my path has curves that seems like a deal breaker.
I know I could use a series of SKActions to accomplish the movement, but in my case it's far preferable to have the physics engine handle the movement for me.
My question is basically whether or not this is something the SpriteKit physics engine can accommodate via something I've missed in the documentation (or if I'm somehow misunderstanding the sliding joint)?
Why is "physics" more preferable? Once you're on rails, you aren't really utilizing the physics engine. If you're looking for semi-realistic y-axis yaw as it rumbles down the track, try doing a random rotation about that axis.
You could also try utilizing the SKNode.physicsBody as well. According to Apple's docs, your SKNode doesn't participate in physics simulations until you attach one.
https://developer.apple.com/documentation/spritekit/sknode/1483117-physicsbody
Giving it mass and other physical properties could simulate slowing down, speeding up, etc.
Otherwise, you will have to do a lot of complicated math to apply physical forces in the direction you want the train to go.

How to create a soft body in SceneKit

So.
After many years of iOS development I said it's time to try to do a little game for myself. Now I chose to do it using Apple's SceneKit since it looks like it provides everything I need.
My problem is that I've stumbled upon a huge problem (for me) and searching on Google doesn't yeld any results.
Any idea how do I go about having an object (a sphere for that matter) that deforms itself, say, because of a gravitational force. So basically it should squash on impact with the ground.
Or, how do I go about deforming it when it collides with other spheres, like a soft beach ball would?
Any starting point along those lines would be helpful.
I can post my code here, but I'm afraid it has nothing to do with my problem since I really don't know where to start.
Thanks!
Update
After doing a bit more reading I think that what I want could be doable with Vertex Shaders. Is that a right path to follow?
For complicated animations, you'll generally be better off using a 3D modeling tool like Blender, Maya, or Cheetah3D to build the body and construct the animation. Those tools let you think at a higher level of abstraction. Then you can export that model to Collada (DAE) format and then import it into SceneKit.
https://en.wikibooks.org/wiki/Blender_3D:_Noob_to_Pro/Basic_Animation/Bounce has a tutorial on building a deforming, bouncing ball using Blender.
SceneKit only does physics using rigid bodies. If you want something to deform, you would have to do it yourself.
It is probably because SceneKit has no way of knowing how an object should be deformed. Should it just compress, should it compress in one direction and expand in all others to preserve it's volume, should only part of the model compress and the rest stay rigid (like the tires on a car).
What you could try is wait for a collision to occur and do the following
calculate and store the velocity after the bounce
disable collision checking on the object
run an animation for the "squash"
enable collision checking on the object
apply the calculated velocity
It will be entirely up to you how real or cartoony you want to make the bounce look.

Xna collision detection 2d

Hi i am trying to write simple game where there is one player and some simple world like trees or some buildings, player can walk having muchine gun and shoot to world object like trees and finally destroy it, game is top-down so i don't need any gravity. Player can hit a lot of bullets and some monster in world can shoot to. SO there can be a lof of bullets in one time on the screen so i need some good tool to make colision detection. Also important is that player can't now walk on other object, like there is a monster and player and they can't exist in the same place (one shouldn't go on another). Can you recoment me some collision detection engine, mayby should I use Farser or better I should write it my self?
simillar to this http://www.youtube.com/watch?v=u8rWomjyTWI
I have one more question, i am still reading about xna since few days, and i know now that if it goes about colision detection we have pixel or square and circle, now: is there any toll or engine which can pare a texture
mappe it into a polygon and check colision?
Farseer is for physics. Use it if you need complex collision reaction. If you simply need if colission then kill player, you don't need such an engine or library.
Did you read the collision example in the App Hub right?
Link: http://create.msdn.com/en-US/education/catalog/tutorial/collision_2d_perpixel_transformed
Thats probably just enough for your purposes.

How can i add laser effect on fire in corona Sdk

I have started my first game in corona SDK and have covered a lot but now I'm stuck to a laser functionality for the weapons , have not much idea how can I implement this . any guidance please ? I want to throw laser on fire function which have collision effect other particles.Thanks in advance.
Well that is a fairly broad question so I can only answer that on a high level. First off, look at my sample OOP framework for one way to do object oriented programming in Lua:
http://developer.anscamobile.com/code/object-oriented-sample-game-framework
Now whether you use this approach or some other technique to achieve OOP, what you want to do is create a Laser object and every time the player fires instantiate a Laser object at the weapon's position. Then in the Laser's constructor set an enterFrame listener that will move it forward a little bit every frame. By moving a little bit every frame, the laser will smoothly animate forward.
As for collision, if you are using physics in your game then you could make your lasers into physics objects to handle collisions that way. Alternatively, you can do a simple distance check with the laser against every enemy on screen; when the laser is close to an enemy that means the laser hit that enemy.

Collision detect with iterative sampling - should I use an engine (box2d) or roll my own?

thanks for taking the time to read my question.
I'm writing a 2d top-down shooter game. It is currently using Box2d as a physics engine. The thing is, it isn't really using Box2d to it's fullest potential, just for collision detection and the underlying velocity/rotation update loop. Any plans to add real physics would simply be eye-candy, not a game changer.
Now I chose Box2d because I went through 2 other physics engines, and they just couldn't handle the types of collisions I'm detecting. I'm creating several 'bullets' with very high velocities, and I do not want them to be instant hits on their targets. JigLib and Flixel both had the same problem - bullets were not overlapping enemies at the time of the frame update, and thus were not detected as collisions (i.e. the bullets passed through enemies because they moved to fast).
I moved to Box2d because of it's iterative collision sampling, as well as the SetAsBullet method on bodies. And it works great! But now Box2d is giving me troubles too - generating several bullets per second, or at the same time, is severely lowering my fps.
So I removed Box2d to confirm that it was not a rendering limitation... added my own velocity/rotation system, and I can fire hundreds of bullets per second. Great! But its lacking any sort of collision detection.
So the questions:
1) Should I write my own iterative collision engine?
2) Should I give Box2d a try again, perhaps with some tweaks to make adding new bodies faster?
3) Is there some other alternative, maybe a lightweight physics engine that specializes in this?
4) Do you know of any other techniques or design patterns that could be of use?
Thanks so much for your help!
Edit: I should note, there are not just bullets, but larger, slower projectiles as well. I considered ray casting a line segment to the projectile's previous position, and catching intersections, but that won't work for the larger objects :(
It depends on how complex your situation can become, If you are good at math and physics you can rollout a fast engine that can handle simple collisions more faster than you can learn using box2d, but why should anyone invent the bycicle if there are plenty of them already invented so choose one you like a try using it, i recommend using box2d

Resources