cupid added

This commit is contained in:
2026-02-15 12:12:55 +05:30
parent b7d8bb1c8c
commit 3108262326
46 changed files with 4152 additions and 260 deletions
@@ -0,0 +1,22 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CameraFollower : MonoBehaviour
{
[SerializeField]private Vector3 offset;
[SerializeField]private bool autoOffset = false;
[SerializeField]private Transform target;
[SerializeField]private float smoothness = 0.1f;
void LateUpdate()
{
if(target==null){return;}
transform.position = Vector3.Lerp(transform.position, target.position + offset,smoothness);
}
public void SetTarget(Transform _target){
target = _target;
offset = transform.position - target.position;
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7d2364b6fed7b904bb0ad40b7b79de7c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+52
View File
@@ -0,0 +1,52 @@
using System.Collections;
using System.Collections.Generic;
using Mirror;
using UnityEngine;
public class Player : NetworkBehaviour
{
[SerializeField]private float movingSpeed;
[SyncVar]
private Vector2 input;
[SyncVar(hook = nameof(OnColorChanged))]
private Color color;
void Start()
{
if(isServer){
SetPlayer();
}
if(isLocalPlayer){
FindObjectOfType<CameraFollower>().SetTarget(transform);
}
}
void SetPlayer(){
color = new Color(Random.Range(0f,1f),Random.Range(0f,1f),Random.Range(0f,1f));
}
void OnColorChanged(Color oldValue, Color newValue){
GetComponent<MeshRenderer>().material.color = newValue;
}
// Update is called once per frame
void Update()
{
if(isLocalPlayer){
Vector2 m_input = new Vector2(Input.GetAxis("Horizontal"),Input.GetAxis("Vertical"));
if(isServer){
input = m_input;
}else{
CmdSetInput(m_input);
}
}
if(isServer){
transform.Translate(new Vector3(input.x,0,input.y)*movingSpeed);
}
}
[Command]
void CmdSetInput(Vector2 _input){
input = _input;
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3a7be0347e7dc43449adcbd1121e447e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: