我已经编写了代码来通过单击鼠标来移动角色来创建策略游戏
但是将代码附加到角色后,我看不到正确的动作 我的代码问题在哪里?
.data
array: .word 2,3,1,5,6,7,1,4,8,8 #elements
N: .word 10 # 10 elements
key: .word 0
int: .word 9
search:
la $a0, array
la $t0, N
lw $t0, ($t0)
sll $t0, $t0, 2
addi $t0, $t0, -4
add $a1, $a0, $t0
la $a0, array
jal isort #insert function from other function
li $v0, 4
la $a0, enterKey # Display text
syscall
li $v0,5 # read input
syscall
sw $v0, key
syscall
move $t0, $s0
lw $t1, N
lw $t2, ($t0)
li $t3,0 # $t3 i = 0
lw $t4, int
lw $t5, key
lw $t6, int
loopKey:
beq $t3, $t1, endKey # if i = n, loop ends
bne $t2, $t5, condKey # if the elements are not equal
move $t4, $t3 # assign index found to variable
j endKey
condKey:
addi $t3, $t3, 1 # i++
addi $t0, $t0, 4
lw $t2, ($t0)
j loopKey
endKey:
beq $t4, $t6, noKey #does not appear to even work???
li $v0, 4
la $a0, keyFmsg
syscall
li $v0, 1
add $t4, $t4, 1 # have to add 1 for location not index
add $a0, $zero, $t4 # prints the location
syscall
j displayMenu
noKey: #not working idk why
li $v0, 4
la $a0, keyNFmsg
syscall
j displayMenu
答案 0 :(得分:1)
您没有在“条件代码”部分中指定“目标轮播”
您必须在if第二部分中添加以下命令
transform.rotation = targetRotation;
此外,hitdist变量必须为零
也就是说,您的代码如下:
var smooth:int=1;
private var targetPosition:Vector3;
function Update () {
if(Input.GetKeyDown(KeyCode.Mouse0))
{
var playerPlane = new Plane(Vector3.up, transform.position);
var ray = Camera.main.ScreenPointToRay (Input.mousePosition);
var hitdist = 1.0;
if (playerPlane.Raycast (ray, hitdist)) {
var targetPoint = ray.GetPoint(hitdist);
targetPosition = ray.GetPoint(hitdist);
var targetRotation = Quaternion.LookRotation(targetPoint - transform.position);
}
}
transform.position = Vector3.Lerp (transform.position, targetPosition, Time.deltaTime * smooth);
}