I
I
ILIIA22892019-12-07 22:46:51
Unity
ILIIA2289, 2019-12-07 22:46:51

Error Unity.2019.2.13f1?

Goal: we need the sword to rotate in z by 47, and after 0.3 seconds, return to its initial position.
unity errors
1 error
Non-invocable member 'Transform.rotation' cannot be used like a method.
2 error
Assets\Scripts\Game.cs(30,15): error CS1061: 'GameObject' does not contain a definition for 'trasnform' and no accessible extension method 'trasnform' accepting a first argument of type 'GameObject' could be found (are you missing a using directive or an assembly reference?)
Code
using System.Collections;
using System.Collections.Generic;
using UnityEngine.UI;
using UnityEngine;
public class Game : MonoBehavior
{
public GameObject sword;
public GameObject shield;
public static int money;
public static int gems;
public static int life;
void Start()
{
print("Game Started - by Illia");
life=100;
}
public void atack0()
{
StartCoroutine(atack0());
}
IEnumerator atack0()
{
sword.transform.rotation(0f, 0f, 47f);
yield return new WaitForSeconds(0.3f);
sword.transform.rotation(0f, 0f, 1f);
}
}
Well, or here's a screenshot of the
5decbbed96f30782643130.png
PS script, if you know, just write the line that you need to change, and change it

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikolay Alekseev, 2019-12-09
@VariusRain

spoiler
Помимо того, что выкладывать код скриншотами - против правил, есть ещё функция оформления кода. Красиво читабельно, понятно. Чем понятнее оформлен ваш код, тем быстрее вы получите ответ.

To the point: in order to understand what is wrong in your code, please learn how to read the text of the error. It says 100% of the information needed to solve the problem.
In your case: Non-invocable member 'Transform.rotation' cannot be used like a method.
You can't use a class member as a method , as a function , if that's more convenient for you.
You are trying to set a rotation by calling a rotation and giving it coordinates.
The second mistake, in principle, has the same roots. Just read the documentation on working with position and rotation.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question