- Home /
How to make a game like Blek??
I want a game like Blek can anyone help me how to make a replica of that game I already searched over the internet but it couldn't help me i a beginner in this Game development thing and I want this kind of Game for my College project can anyone help me with that i just want to know how the mechanism works i mean i used Trail Renderer and using rigidbody2d.velocity , i am able to move the trail in horizontal line but i want to move it like blek game and i am unable to get the logic what kind of code should i used to get the game play like blek Please help me thank you.
Answer by rodude123 · Jun 29, 2017 at 02:36 PM
Show what code you created and what code you tried to make it move like blek. Have you tried to get the mouse position and its direction? Once you got the mouse position and its direction you need to draw the trail following the mouse position and direction. You could record the position into an array of vector2's then draw them programmatically using code afterwards. Hope this helps
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class touch : $$anonymous$$onoBehaviour {
private Rigidbody2D myRigidbody;
private float movementSpeed = 3f;
public Transform target;
// Use this for initialization
void Start () {
myRigidbody = GetComponent<Rigidbody2D> ();
}
// Update is called once per frame
void Update () {
if (((Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.$$anonymous$$oved) || Input.Get$$anonymous$$ouseButton (0)))
{
Plane objPlane = new Plane (Camera.main.transform.forward * -1, this.transform.position);
Ray mRay = Camera.main.ScreenPointToRay (Input.mousePosition);
float rayDistance;
if (objPlane.Raycast (mRay, out rayDistance))
this.transform.position = mRay.GetPoint (rayDistance);
Vector3 touchDeltaPosition = Input.mousePosition;
//transform.Translate(touchDeltaPosition.x * movementSpeed, touchDeltaPosition.y * movementSpeed, 0);
myRigidbody.velocity = new Vector2(movementSpeed,0);
Debug.Log(touchDeltaPosition);
}
}
}
this is my Code Help $$anonymous$$e Sir thank you
This is good you just need to generate particles using the particle system and make it follow the object so attach it to the object in someway