- using UnityEngine;
- public class GerakPemukul : MonoBehaviour
- {
- public float batasAtas;
- public float batasBawah;
- public float kecepatan;
- public string axis;
- // Start is called before the first frame update
- void Start()
- {
- }
- // Update is called once per frame
- void Update()
- {
- float gerak = Input.GetAxis(axis) * kecepatan * Time.deltaTime;
- float nextPos = transform.position.y + gerak;
- if (nextPos > batasAtas)
- {
- gerak = 0;
- }
- if (nextPos < batasBawah)
- {
- gerak = 0;
- }
- transform.Translate(0, gerak, 0);
- }
- }
[text] d
Viewer
*** This page was generated with the meta tag "noindex, nofollow". This happened because you selected this option before saving or the system detected it as spam. This means that this page will never get into the search engines and the search bot will not crawl it. There is nothing to worry about, you can still share it with anyone.
Editor
You can edit this paste and save as new: