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. Voting for the Unity Awards are OPEN! We’re looking to celebrate creators across games, industry, film, and many more categories. Cast your vote now for all categories
    Dismiss Notice
  3. Dismiss Notice

cs(6,13): error CS1520: Class, struct, or interface method must have a return type

Discussion in 'Editor & General Support' started by victeldo_unity, Oct 26, 2018.

?

is it unethical to copy other people's code (If open source) if I don't know how to do c# myself?

  1. Yes - you need to make your own code

    0 vote(s)
    0.0%
  2. No - but you need to accredit the source

    0 vote(s)
    0.0%
  3. No - you don't need to accredit as long as it's open source.

    0 vote(s)
    0.0%
  1. victeldo_unity

    victeldo_unity

    Joined:
    Sep 24, 2018
    Posts:
    24
    Hey guys, I've been sitting like an idiot for the last 45 minutes and I've not been able to get this 'return type'. Could someone help? If I set the private GetUpdate() to private void GetUpdate() then the mouseposition and moveSpeed starts to have a recognition problem. Unity presents "error CS0103: The name `mousePosition' does not exist in the current context" and "error CS0103: The name `moveSpeed' does not exist in the current context".
    I'm really confused and I'm new to C# and Unity. I've only managed to copy the code and put them where I need it to be (That's allowed right, as long as it's open source and all?) - is it unethical to copy paste other people's code (If open source) and use it in my own game if I don't know how to program and C#? Do I have to accredit them always? That's a side question, but I need this thing fixed really badly! Thanks in advance.
    This is the code:
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class CharacterMovement : MonoBehaviour {
    6.     private GetUpdate()
    7.     {
    8.        if  (Input.GetMouseButton(1))
    9.         {
    10.             mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
    11.             Vector2 tmpDir = mousePosition - transform.position;
    12.             transform.position = Vector2.Lerp(transform.position, mousePosition, moveSpeed * 1f / tmpDir.magnitude * Time.deltaTime);
    13.         }    
    14.     }
    15. }
    16.  
     
  2. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,383
    You aren't going to get anywhere coding until you make an effort to learn. Download Visual Studio and start doing some C# tutorials or use the Learn section of the Unity Website.
     
    victeldo_unity and Vryken like this.
  3. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    You haven't declared most of the variables that you are trying to use ("..does not exist.."). As mentioned, probably best to step back from Unity and learn a little C# first separately.
     
    victeldo_unity and Vryken like this.
  4. victeldo_unity

    victeldo_unity

    Joined:
    Sep 24, 2018
    Posts:
    24
    Yeah, I've just realized. But sadly, I dumbly had said that I was going to make a Unity game to my school and I'm like 40% done (If I will say that 60% is scripting) as I got the models and maps in place. I'll try to learn whenever I can but is there anything I can do now? Like I have a really primal understanding of the language but I know a bit of another language with a similar format (CSS). So if you'd prefer not to say so I could try to learn it myself, I understand and thank you, but is there anything that I have to add (Like how do I declare variables)?
     
  5. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,383
    You might want to pick up Playmaker then.
     
  6. victeldo_unity

    victeldo_unity

    Joined:
    Sep 24, 2018
    Posts:
    24
    Oh, thanks a lot. I was kinda familiar with Scratch so I think this will help :)
     
  7. victeldo_unity

    victeldo_unity

    Joined:
    Sep 24, 2018
    Posts:
    24
    but other than that, how could I fix the code I presented initially? It's having an issue identifying certain variables and I'm not sure on how do I define/declare the variables of the code presented.
     
  8. victeldo_unity

    victeldo_unity

    Joined:
    Sep 24, 2018
    Posts:
    24
    Well, it seems pretty hard since the script is not loading right now (Btw I had managed to declare the variables lol. took me a while to learn). Do you know how to fix this warning? :
    The referenced script (Character Movement (Whale)) on this Behaviour is missing!
    ? I freaked out when it wasn't working then I saw this
     
  9. victeldo_unity

    victeldo_unity

    Joined:
    Sep 24, 2018
    Posts:
    24
    Never mind, I just realized that was impossibly hard code for a newb like me. Found out how to do WASD instead, finally, I can move my character!