Jump to content

pugdug808

Member
  • Posts

    45
  • Joined

  • Last visited

Posts posted by pugdug808

  1. i really enjoy anime i like it more than american shows, i think its fantastic im still new-ish compared to people who have completed over 100. anyway so what are some of your favorite shows, or ones you highly recommend. i just finished future diary and it was absolutely amazing! i watched it dubbed i was surprised because it was a rather well done dub. 

  2. wtf is going on i have looked through these scripts a ton of times and absolutely cannot find whats wrong! so it is code for a 2d platformer and what happens is its supposed to collide with stuff with the "collisions Layer" and everything is setup so im just trying to find any code errors

    using UnityEngine;using System.Collections;[RequireComponent(typeof(PlayerPhysics))]public class playerController : MonoBehaviour {		public float gravity = 20;    public float speed = 8;    public float acceleration = 12;		private float currentSpeed;	private float targetSpeed;	private Vector2 amountToMove;		private PlayerPhysics playerPhysics;			void Start() {		playerPhysics = GetComponent<PlayerPhysics>();			}	void Update() {		targetSpeed = Input.GetAxisRaw("Horizontal")* speed;			currentSpeed = IncrementTowards(currentSpeed, targetSpeed,acceleration);				amountToMove.x = currentSpeed;		amountToMove.y -= gravity * Time.deltaTime;		playerPhysics.Move(amountToMove * Time.deltaTime);	}	private float IncrementTowards(float n, float target,float a) {		if(n == target) {			return n;		}		else {			float dir = Mathf.Sign(target - n);			n+= a * Time.deltaTime * dir;			return (dir == Mathf.Sign(target-n))? n: target;	}	}	}

    the two are dependent on each other

    using UnityEngine;using System.Collections;[RequireComponent(typeof(BoxCollider))]public class PlayerPhysics : MonoBehaviour {		public LayerMask collisionMask;		private BoxCollider collider;	private Vector3 s;	private Vector3 c;		private float skin = .005f;		[HideInInspector]	public bool grounded;		Ray ray;	RaycastHit hit;		void Start() {	    collider = GetComponent<BoxCollider>();		s = collider.size;		c = collider.center;	}		public void Move(Vector2 moveAmount) {				float deltaY = moveAmount.y;		float deltaX = moveAmount.x;		Vector2 p = transform.position;				for (int i = 0; i<=3; i ++) {		     float dir = Mathf.Sign(deltaY);		     float x = (p.x + c.x - s.x/2) + s.x/2 * i;	         float y = p.y + c.y + s.y/2 * dir;						ray = new Ray(new Vector2(x,y), new Vector2(0,dir));						if(Physics.Raycast(ray,out hit,Mathf.Abs(deltaY),collisionMask	)) {				float dst = Vector3.Distance (ray.origin, hit.point);								if (dst > skin) {				 deltaY = -dst + skin;				}				else{					deltaY = 0;				}				grounded = true;			    break;			}					}		 Vector2 finalTransform = new Vector2(deltaX,deltaY);				transform.Translate(finalTransform);	}}

    if anyone one could help that would be very much appreciated because frankly i do not know what to do at this point  

×
×
  • Create New...