Skip to content

Instantly share code, notes, and snippets.

View ahmadnaser's full-sized avatar

Ahmad Naser ahmadnaser

View GitHub Profile
@ahmadnaser
ahmadnaser / get the char as an output of two array of bytes summation
Created March 12, 2016 23:46
get the char as an output of two array of bytes summation
//convert string to array of chars
string text = "abcd";
char[] array2 = text.ToCharArray();
//1-convert char to array of bytes
//2-sumation of two array of bytes
//3-return the value of the two arays as array of chars
//4-get the char as an output of two array of bytes summation
//For More Information visit: http://www.ssec.wisc.edu/~tomw/java/unicode.html#x0600
using UnityEngine;
using System.Collections;
public class LevelLoader : MonoBehaviour
{
public int calculations = 10000;
public int iterations = 10000;
public bool inAwake = true;
public bool inStart = true;
@ahmadnaser
ahmadnaser / PlayerKeyboardController
Created December 29, 2015 09:17
Allow player to move and jump based on keyboard arrows and space jump
using UnityEngine;
using System.Collections;
public class PlayerKeyboardController : MonoBehaviour
{
//to make movement more smoother
//Change Mass to 0.1f
//Linear Drag to 0.4f
@ahmadnaser
ahmadnaser / Joystick.cs for mobile buttons
Created December 29, 2015 07:07
add Right,Left,Jump Capabilities for UI buttons in UNITY
using UnityEngine;
using System.Collections;
using UnityEngine.EventSystems;
public class Joystick : MonoBehaviour, IPointerUpHandler, IPointerDownHandler {
private PlayerJoystick playerjoystick;
public GameObject Player;
private float force = 300;
void Start() {
@ahmadnaser
ahmadnaser / PlayerSmoothFollow.cs
Created December 29, 2015 07:02
Allow Camera to Smart smooth follow the player attached to main camera
using UnityEngine;
using System.Collections;
public class PlayerSmoothFollow : MonoBehaviour {
[SerializeField] private Transform target = null;
[SerializeField] private float distance = 20f;
[SerializeField] private float height = 5f;
[SerializeField] private float damping = 5f;
[SerializeField] private bool smoothRotation = true;
@ahmadnaser
ahmadnaser / PlayerJoystick.cs
Created December 29, 2015 06:57
Allow player to move based on three buttons - left,right,jump
using UnityEngine;
using System.Collections;
public class PlayerJoystick : MonoBehaviour
{
public float speed = 0.1f, maxVelocity = 0.05f;
private Rigidbody2D myBody;
private Animator anim;
private bool moveLeft, moveRight;
@ahmadnaser
ahmadnaser / MultipleLines.cs
Last active May 20, 2018 21:32
How to draw multiple lines in Unity and c# with different colors
using UnityEngine;
using System.Collections;
public class MultipleLines : MonoBehaviour
{
public GameObject circlePointPrefab;
public GameObject currentLineRenderer;
public GameObject lineRendererPrefab;
public Material drawingMaterial;
private Vector3 previousPosition, currentPostion;
@ahmadnaser
ahmadnaser / SingleLine.cs
Created December 8, 2015 09:03
How to draw a single Line in c# and Unity
using UnityEngine;
using System.Collections;
public class SingleLine : MonoBehaviour {
public GameObject circlePointPrefab;
public GameObject currentLineRenderer;
public GameObject lineRendererPrefab;
public Material drawingMaterial;
private Vector3 previousPosition,currentPostion;
private bool clickStarted;
@ahmadnaser
ahmadnaser / SinglePoint.cs
Created December 8, 2015 07:57
Generate Points from mouse click in c# unity
using UnityEngine;
using System.Collections;
public class SinglePoint : MonoBehaviour {
public GameObject circlePointPrefab;
public GameObject currentLineRenderer;
public GameObject lineRendererPrefab;
public Material drawingMaterial;
// Use this for initialization
@ahmadnaser
ahmadnaser / Pie Chart In Js for numerator denominator
Created December 5, 2015 22:24
Numerator/Denominator in HTML CSS JS
<!doctype html>
<html>
<head>
<title>Pie Chart</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/1.0.2/Chart.js"></script>
<script src="https://code.jquery.com/jquery-1.10.1.js"></script>
</head>
<body>