Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Please Help I dont know whats wrong

Discussion in 'Scripting' started by Carlitosjft, Dec 24, 2020.

  1. Carlitosjft

    Carlitosjft

    Joined:
    Mar 18, 2016
    Posts:
    7
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using UnityEngine.EventSystems;

    public class MultiJoy : MonoBehaviour, IPointerDownHandler,
    IPointerUpHandler, IDragHandler
    {
    public RectTransform pad;
    public RectTransform stick;

    public void OnDrag(PointerEventData eventData)
    {
    stick.positioin = eventData.position;

    stick.plocalPosition =
    Vector2.ClampMagnitude(eventData.position -
    (Vector)pad.position, pad.rect.width * 0.5f);
    }

    public void OnPointerDown(PointerEventData eventData)
    {
    pad.position = eventData.position;
    }

    public void OnPointerUp(PointerEventData eventData)
    {
    stick.localPosition = Vector2.zero;
    }
    }

    Error that it gives is:
    Assets\MultiJoy1.cs(14,15): error CS1061: 'RectTransform' does not contain a definition for 'positioin' and no accessible extension method 'positioin' accepting a first argument of type 'RectTransform' could be found (are you missing a using directive or an assembly reference?)

    Assets\MultiJoy1.cs(16,15): error CS1061: 'RectTransform' does not contain a definition for 'plocalPosition' and no accessible extension method 'plocalPosition' accepting a first argument of type 'RectTransform' could be found (are you missing a using directive or an assembly reference?)

    Assets\MultiJoy1.cs(18,10): error CS0246: The type or namespace name 'Vector' could not be found (are you missing a using directive or an assembly reference?)
     
  2. Yoreki

    Yoreki

    Joined:
    Apr 10, 2019
    Posts:
    2,587
    None of these exist.
    You misspelled position, added a p before localPosition, and meant either Vector2 or Vector3.

    That said, please have a read: http://plbm.com/?p=220
    Please use code tags next time as well :)
     
    Kurt-Dekker likes this.