How AnimatedSprite smoothly move on line with on touch and constant speed in andengine? - andengine

I am developing demo game application in my game application i want to move my animatedSprite on perfect line that is drawn by user with exactly on touch . And my sprite have to move its constant speed whether user draw line fast or slow.
currently i have used pathmodifier but in this case after user draw path for sprite then and then only possible to move my sprite because pathmodifier takes path and in path we have to give all points statically (predefined) and its length . like below
final Path path = new Path(xListLength);
PathModifier pathModifier = new PathModifier(velocity, path);
but i want my sprite move exactly when user touch on it and when user draw path for it my sprite follow its path having its constant speed. how can i do this in andengine .?

Related

How to convert a position into starting point for app using unity and ARKit?

Trying to develop an AR app.When the app is opened,at that point the device location is (0,0,0) that is if I print or display my coordinates it will be (0,0,0).I want to create a starting point like at the entrance of a door.When other users using my app can open the app anywhere.
What I am trying to do is I already kept an AR at the entrance of the door.Users open app at random position which become their starting point, all AR objects will appear.When they pass through the AR object ,I want the coordinates of their device be(0,0,0).But if I run the below code in unity editor it takes the camera to the position where app has started.I am looking to convert the entrance position into App starting point.
Camera.main.transform.position=new Vector3(0,0,0);
From what I understand if we change the position of camera in app it can show glitches
Your question is very unclear -.-
but IF what you try doing is reset the camera to (0,0,0) while keeping all game objects at the same relative position to it you could try:
var localToCamera = Camera.main.transform.worldToLocalMatrix;
var obj = GameObject.FindSceneObjectsOfType(typeof(GameObject));
foreach (var o in obj)
{
var go = (o as GameObject);
go.transform.FromMatrix(localToCamera * go.transform.localToWorldMatrix);
}
_
EDIT:
what the UGLY code above is supposed to do:
it's going to crawl through all GameObjects and reposition them in such a way that if you set the camera to position (0,0,0) and facing (0,0,1), they will remain at the same position and orientation relatively to the camera.
notice that the camera itself WILL get repositioned to (0,0,0) and facing (0,0,1) after this code is executed because
Camera.main.transform.worldToLocalMatrix * localToWorldMatrix == identity
EDIT:
I can't put this code in the comments because it's too long.
try
// code from the top of my head here, syntax or function names might not be exact
var forward = arcamera.transform.forward;
forward.y = 0;
arcamera.transform.rotation = Quaternion.LookDirection(forward);
// now the camera forward should be in the (x,z) plane
UnityARSessionNativeInterface.GetARSessionNativeInterface().SetWorldOrigin(arcamera.transform);
// since you did not tilt the horizontal plane, hopefully the plane detection still detected vertical and horizontal planes

Why Particplesystem Position is wrong while attached to a GameObject?

I'm working with unity 5(2D project).
I attached a ParticleSystem to a GameObject(an UI Button). now i can see both of them but they are not in the same position.
I move particplesystem manually and put both object in the same position .but when i move my object they will not move togothere... particlesystem will move lower and objects will have different positions.
thank you from #Code Clown and #Noel Widmer.
as my friends said at first i should transforms the GUI's screen position to world position and then to the particle system's local position in each update.
I made this by these two line of codes.
Vector3 p = Camera.main.ScreenToWorldPoint(GameObject.Find("MyObject").transform.position);
transform.localPosition = p;

libgdx moving animated actor following the finger touch

In my game one crocodile is in water i have to guide that crocodile in water ,
it will follow my finger touch and will finish the path.
it should rotate when there is turn.
what approach should i use in libgdx...
Thanks
There is only one approach.
You capture the input (implement InputListener), unproject the pointer to your game world (Camera.unproject(...)), calculate the difference between the target vector and the position of the object that should follow it and move it in this direction, or use A* in case there are obstacles in between, calculate an appropriate path and then move along that path.

How to get midpoint value in OpenGLES in iPhone?

I am new to game development. Currently I am working in simple game application, using GL_Line to draw a line and GL_Triangle strip to draw a (ball)image. Normally ball images are moving from left to right direction. When the user tab on a screen, then the line draw (top to bottom) inside the screen and to touch a ball image. So I tried to get the midpoint values from line and ball image, but i cannot know, how to start this?
If you have a line that goes from (ax,ay) to (bx, by), the mid-point of the line is just ((ax + bx) / 2.0, (ay + by) / 2.0)).

Lightning effect in opengl es

Is there a way to create a lightning effect on the iPhone using opengl?(like this app)
Right now I have modified the glpaint sample to draw random points around a line (between two points that the user touches) and then connecting them, but the result is a zigzag line that constantly jumps around and lags horribly on the actual device.
you'll probably just want to make a triangle strip from the center of the device to the point that is being touched, then apply a drawn lightning texture to that resultant polygon.
You can animate the texture in order to get the jumping lightning effect.
A simple way to create a lightning effect is to compute the lightning path using a 2D Perlin function, rendering it to a glow buffer, blurring it with a Gaussian blur shader, and merging it with the scene. You can make the lightning move by computing two paths (start and end) with an identical number of path nodes and moving each node of the start path successively towards the corresponding node of the end path. Once the end path has been reached, it becomes the start path and a new end path is computed.